Socket
Socket
Sign inDemoInstall

pkg-conf

Package Overview
Dependencies
15
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.0 to 3.1.0

138

index.d.ts

@@ -1,62 +0,92 @@

export type Config = {[key: string]: unknown};
declare namespace pkgConf {
type Config = {[key: string]: unknown};
export interface Options<ConfigType extends Config> {
interface Options<ConfigType extends Config> {
/**
Directory to start looking up for a `package.json` file.
@default process.cwd()
*/
cwd?: string;
/**
Default config.
@default {}
*/
defaults?: ConfigType;
/**
Skip `package.json` files that have the namespaced config explicitly set to `false`.
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.
@default false
@example
```
{
"name": "some-package",
"version": "1.0.0",
"unicorn": false
}
```
*/
skipOnFalse?: boolean;
}
}
declare const pkgConf: {
/**
* Directory to start looking up for a `package.json` file.
*
* @default process.cwd()
*/
cwd?: string;
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.
@param namespace - The `package.json` namespace you want.
@returns A `Promise` for the config.
@example
```
// {
// "name": "some-package",
// "version": "1.0.0",
// "unicorn": {
// "rainbow": true
// }
// }
import pkgConf = require('pkg-conf');
(async () => {
const config = await pkgConf('unicorn');
console.log(config.rainbow);
//=> true
})();
```
*/
<ConfigType extends pkgConf.Config = pkgConf.Config>(
namespace: string,
options?: pkgConf.Options<ConfigType>
): Promise<ConfigType & pkgConf.Config>;
/**
* Default config.
*
* @default {}
*/
defaults?: ConfigType;
Same as `pkgConf()`, but runs synchronously.
@param namespace - The `package.json` namespace you want.
@returns Returns the config.
*/
sync<ConfigType extends pkgConf.Config = pkgConf.Config>(
namespace: string,
options?: pkgConf.Options<ConfigType>
): ConfigType & pkgConf.Config;
/**
* Skip `package.json` files that have the namespaced config explicitly set to `false`.
*
* 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.
*
* @default false
*
* @example
*
* {
* "name": "some-package",
* "version": "1.0.0",
* "unicorn": false
* }
*/
skipOnFalse?: boolean;
}
@param config - The `config` returned from any of the above methods.
@returns The filepath to the `package.json` file or `null` when not found.
*/
filepath(config: pkgConf.Config): string | null;
/**
* 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.
*
* @param namespace - The `package.json` namespace you want.
* @returns A `Promise` for the config.
*/
export default function pkgConf<ConfigType extends Config = Config>(
namespace: string,
options?: Options<ConfigType>
): Promise<ConfigType & Config>;
// TODO: Remove this for the next major release
default: typeof pkgConf;
};
/**
* Same as `pkgConf()`, but runs synchronously.
*
* @param namespace - The `package.json` namespace you want.
* @returns Returns the config.
*/
export function sync<ConfigType extends Config = Config>(
namespace: string,
options?: Options<ConfigType>
): ConfigType & Config;
/**
* @param config - The `config` returned from any of the above methods.
* @returns The filepath to the `package.json` file or `null` when not found.
*/
export function filepath(config: Config): string | null;
export = pkgConf;

@@ -59,4 +59,5 @@ 'use strict';

module.exports = pkgConf;
// TODO: Remove this for the next major release
module.exports.default = pkgConf;
module.exports.filepath = filepath;
module.exports.sync = sync;
{
"name": "pkg-conf",
"version": "3.0.0",
"version": "3.1.0",
"description": "Get namespaced config from the closest package.json",

@@ -16,3 +16,3 @@ "license": "MIT",

"scripts": {
"test": "xo && ava && tsd-check"
"test": "xo && ava && tsd"
},

@@ -45,4 +45,4 @@ "files": [

"devDependencies": {
"ava": "^1.2.1",
"tsd-check": "^0.3.0",
"ava": "^1.4.1",
"tsd": "^0.7.2",
"xo": "^0.24.0"

@@ -49,0 +49,0 @@ },

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc