New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

read-conf

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

read-conf

reads a config file

  • 0.3.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

read-conf

reads a config file.

Using if available:

  • babel-register
  • coffeescript/register
  • coffee-script/register
  • ts-node/register

Can also watch a config file and all of its dependencies using chokidar and recursive-uncache.

Install

npm install --save read-conf

Usage

readConf = require("read-conf")
// readConf(options:Object):Promise
conf = await readConf({name:"filename"})
conf.mtime // contains modified time of config file
// short form is allowed
packageJson = await readConf("package")

// has sophisticated watch functionality 
unwatch = await readConf({name: "package",watch: true, cb: (conf) => {
  // config has changed
  // can be async
  return await someStartup(conf)
}, cancel: () => {
  // config has changed, but last cb didn't return yet
  // cb will be called again, once this functions returns
  // implement some sort of sleep to wait for other files to change
  await Promise((resolve) => {setTimeout(resolve, 100)})
  // can be async
  return await someTearDown()
}})
unwatch() // once you want to cancel watching

// cb syntax also possible without watch
unwatch = await readConf({name: "package",watch: false, cb: (conf) => {

}})
unwatch() // empty function, save to call
Options
Nametypedefaultdescription
nameString-filename of the config
extensionsArray["js","json","coffee","ts"]extensions to look out for
foldersArray or Stringprocess.cwd()folder(s) to search in, can be relative to cwd or absolute
filenameString-absolute path to the config
defaultObject-the config will be merged into this
assignObject-this will be merged into the config
cbFunction-callback which is called with config obj
watchBooleanfalseuses watch
cancelFunction-only with watch. Is called on file change when cb is still busy

## License
Copyright (c) 2017 Paul Pflugradt
Licensed under the MIT license.

Keywords

FAQs

Package last updated on 05 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc