Simple email application for Android. Original source code: https://framagit.org/dystopia-project/simple-email
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
2.7 KiB

  1. # pkg-conf [![Build Status](https://travis-ci.org/sindresorhus/pkg-conf.svg?branch=master)](https://travis-ci.org/sindresorhus/pkg-conf)
  2. > Get namespaced config from the closest package.json
  3. Having tool specific config in package.json reduces the amount of metafiles in your repo (there are usually a lot!) and makes the config obvious compared to hidden dotfiles like `.eslintrc`, which can end up causing confusion. [XO](https://github.com/sindresorhus/xo), for example, uses the `xo` namespace in package.json, and [ESLint](http://eslint.org) uses `eslintConfig`. Many more tools supports this, like [AVA](https://ava.li), [Babel](https://babeljs.io), [nyc](https://github.com/istanbuljs/nyc), etc.
  4. ## Install
  5. ```
  6. $ npm install pkg-conf
  7. ```
  8. ## Usage
  9. ```json
  10. {
  11. "name": "some-package",
  12. "version": "1.0.0",
  13. "unicorn": {
  14. "rainbow": true
  15. }
  16. }
  17. ```
  18. ```js
  19. const pkgConf = require('pkg-conf');
  20. (async () => {
  21. const config = await pkgConf('unicorn');
  22. console.log(config.rainbow);
  23. //=> true
  24. })();
  25. ```
  26. ## API
  27. It [walks up](https://github.com/sindresorhus/find-up) parent directories until a `package.json` can be found, reads it, and returns the user specified namespace or an empty object if not found.
  28. ### pkgConf(namespace, [options])
  29. Returns a `Promise` for the config.
  30. ### pkgConf.sync(namespace, [options])
  31. Returns the config.
  32. #### namespace
  33. Type: `string`
  34. The package.json namespace you want.
  35. #### options
  36. ##### cwd
  37. Type: `string`<br>
  38. Default: `process.cwd()`
  39. Directory to start looking up for a package.json file.
  40. ##### defaults
  41. Type: `Object`<br>
  42. Default config.
  43. ##### skipOnFalse
  44. Type: `boolean`<br>
  45. Default: `false`
  46. Skip `package.json` files that have the namespaced config explicitly set to `false`.
  47. Continues searching upwards until the next `package.json` file is reached. This can be useful when you need to support the ability for users to have nested `package.json` files, but only read from the root one, like in the case of [`electron-builder`](https://github.com/electron-userland/electron-builder/wiki/Options#AppMetadata) where you have one `package.json` file for the app and one top-level for development.
  48. Example usage for the user:
  49. ```json
  50. {
  51. "name": "some-package",
  52. "version": "1.0.0",
  53. "unicorn": false
  54. }
  55. ```
  56. ### pkgConf.filepath(config)
  57. Pass in the `config` returned from any of the above methods.
  58. Returns the filepath to the package.json file or `null` when not found.
  59. ## Related
  60. - [read-pkg-up](https://github.com/sindresorhus/read-pkg-up) - Read the closest package.json file
  61. - [read-pkg](https://github.com/sindresorhus/read-pkg) - Read a package.json file
  62. - [find-up](https://github.com/sindresorhus/find-up) - Find a file by walking up parent directories
  63. ## License
  64. MIT © [Sindre Sorhus](https://sindresorhus.com)