1.2.8 • Published 3 years ago

clobfig v1.2.8

Weekly downloads
5
License
GPL-3.0
Repository
github
Last release
3 years ago

clobfig

A configurator library

getting started

clobfig looks for a config/ folder one folder up or in the root of the running application using appRoot. clobfig clobbers all of the files within the config folder found that have 'config.js' in their name and all .json files. The json files are loaded first and are loaded as name.json (ex: pages.json => clobfig.pages). Note: all json files are loaded this way with the exception of config.json

Finally, clobfig provides a mechanism for overridding values from a present package.json file. Using the schema title: "@{title}" tells clobfig to pull this value from the package.json file in the root of the project. You can prime the loading of clobfig by simply passing the values to grab from the package.json with:

  const config = require('clobfig')({ title: "@title" })

usage

/config/config.json:

{
  "value1": "one"
}

/config/config.js:

module.exports = {
  version: "@version"
}

/config/data.json:

{
  "somedata": "somevalue"
}

/package.json:

{
  "title": "example app",
  "version": "0.1.0"
}

/index.js:

const config = require('clobfig')({ title: "@title" })

console.log(config)

The code example above will output:

{ title: "example app", version: "0.1.0", data: { somedata: "somevalue" }, value1: "one" }

1.2.8

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago