Skip to content
This repository has been archived by the owner on Jun 6, 2022. It is now read-only.
/ conjig Public archive

🐣 a minimal universal configuration loader

Notifications You must be signed in to change notification settings

ahdinosaur/conjig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

conjig stability

npm version build status downloads js-standard-style

a minimal universal configuration loader

npm install --save conjig

what

you want to synchronously load a configuration object.

the configuration should be composed of many sources.

dna

install

with npm, run

npm install --save conjig

example

pass options in js

// config.js
const getConfig = require('conjig')

module.exports = getConfig({
  sources: [
    "./config/${NODE_ENV}",
    "./config"
  ]
})

or in package.json

// config.js
const getConfig = require('conjig')

module.exports = getConfig()
{
  "conjig": {
    "sources": [
      "./config/${NODE_ENV}",
      "./config"
    ]
  }
}

usage

getConfig = require('conjig')

config = getConfig(options)

options is an object with:

  • sources: an array of filenames
    • may include template string variables from process.env

config is an object deeply merged with all config objects in sources.

browser

to use in the browser, use the browserify compiler.

in your package.json, add

{
  "browserify": {
    "transform": [
      "conjig/transform"
    ]
  }
}

then when you call require('conjig')() in the browser, it transforms to the result in node during compilation.

license

The Apache License

Copyright © 2016 Michael Williams

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

🐣 a minimal universal configuration loader

Resources

Stars

Watchers

Forks

Packages

No packages published