npm

Share private packages across your team with npm Orgs, now with simplified billing via the aws marketplace!Learn more »

package-dependencies-file-paths

2.0.0 • Public • Published

package-dependencies-file-paths

npm package

Build Status NPM Version NPM Downloads Dependency Status Known Vulnerabilities

Resolve dependencies file paths in a package.json.

Install

$ npm install --save package-dependencies-file-paths

Usage

File Structure

├── node_modules
│   ├─ ...
│   ├─ globby
│   ├─ lodash
│   └─ ...
├── example.js
└── package.json

package.json

{
  //...
  "dependencies": {
    //...
    "globby": "~6.1.0",
    "lodash": "~4.17.2",
    //...
  },
  //...
}

example.js

var packageDependenciesFilePaths = require('package-dependencies-file-paths');
var path = require('path');
 
var cwd = process.cwd();
var options = {
  includeDotFiles: false,
  ignore: [
    '**/{doc,docs,example,examples,fixture,fixtures,spec,test,tests}/**',
    '**/{bower,component}.json',
    '**/{gulpfile,Gruntfile}.js',
    '**/{LICENCE,LICENSE,License,license}',
    '**/*.{spec,test}.js',
    '**/*.{markdown,md,ts}'
  ],
  transformPath: function(filePath) {
    return filePath.replace(cwd + path.sep, '');
  },
  sort: true
};
var pkgJson = require('./package.json');
packageDependenciesFilePaths(pkgJson, options, function(err, filePaths) {
  if(err) return console.error(err.message);
  console.log(JSON.stringify(filePaths, null, 2));
  // Do something with JavaScript and JSON files such as zip them and deploy them to the ☁️
});

Output from code above should look like this:

[
  //...
  "node_modules/glob/common.js",
  "node_modules/glob/glob.js",
  "node_modules/glob/package.json",
  //...
  "node_modules/globby/index.js",
  "node_modules/globby/package.json",
  //...
  "node_modules/lodash/fp/__.js",
  //...
  "node_modules/lodash/package.json",
  //...
  "node_modules/pinky_promise/index.js",
  "node_modules/pinky_promise/package.json",
  //...
]

API

packageDependenciesFilePaths(packageJson, [options], [callback])

Resolve dependencies file paths in packageJson.

packageJson

Type: Object

package.json Object.

[options]

Type: Object

[includeDotFiles]

Type: Boolean

Default: false

[ignore]

Type: String[]

Default: []

See node-glob glob-primer

[dependenciesSets]

Type: String[]

Possible Values: dependencies, devDependencies, peerDependencies

Default: ["dependencies"]

[transformPath]

Type: Function

[sort]

Type: Boolean

Default: false

[callback]

Type: Function

err

Type: Error

filePaths

Type: String[]

License

MIT © Huhgawz

install

npm i package-dependencies-file-paths

Downloadsweekly downloads

0

version

2.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability