Comparing version 1.3.1 to 1.3.2
@@ -9,3 +9,4 @@ module.exports = { | ||
publish: require('./src/publish'), | ||
pack: require('./src/pack') | ||
pack: require('./src/pack'), | ||
getPackage: require('./src/get-package') | ||
}; |
{ | ||
"name": "npm-utils", | ||
"description": "Async NPM shell commands", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"author": "Gleb Bahmutov <gleb.bahmutov@gmail.com>", | ||
@@ -31,3 +31,2 @@ "bugs": { | ||
"cross-spawn-async": "2.1.6", | ||
"glob-promise": "1.0.4", | ||
"lazy-ass": "1.3.0", | ||
@@ -34,0 +33,0 @@ "q": "2.0.3", |
@@ -70,2 +70,11 @@ # npm-utils | ||
### getPackage | ||
Loads `package.json` from a given folder | ||
```js | ||
var pkg = npm.getPackage(folder); | ||
console.log('%s version %s', pkg.name, pkg.version); | ||
``` | ||
### pack | ||
@@ -72,0 +81,0 @@ |
var la = require('lazy-ass'); | ||
var is = require('check-more-types'); | ||
var fs = require('fs'); | ||
var Q = require('q'); | ||
var run = require('./npm-test'); | ||
la(is.fn(run), 'expected run function'); | ||
var glob = require('glob-promise'); | ||
var getPackage = require('./get-package'); | ||
// NPM pack generates file in the format | ||
// <name>-<version>.tgz | ||
function formTarballName(pkg) { | ||
return pkg.name + '-' + pkg.version + '.tgz'; | ||
} | ||
function pack(options) { | ||
options = options || {}; | ||
var folder = options.folder ? options.folder : '.'; | ||
var pkg = getPackage(folder); | ||
la(is.unemptyString(pkg.name) && | ||
is.unemptyString(pkg.version), 'invalid package in folder', folder); | ||
var command = 'npm pack ' + folder; | ||
@@ -14,9 +26,7 @@ return run(command) | ||
// find the generated file in the current folder | ||
return glob('./*.tgz') | ||
.then(function (filenames) { | ||
if (filenames.length === 1) { | ||
return filenames[0]; | ||
} | ||
console.error('found %d archives in %s', filenames.length, folder); | ||
}); | ||
var filename = formTarballName(pkg); | ||
if (!fs.existsSync(filename)) { | ||
return Q.reject(new Error('Cannot find tar file ' + filename)); | ||
} | ||
return filename; | ||
}); | ||
@@ -23,0 +33,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
AI-detected potential security risk
Supply chain riskAI has determined that this package may contain potential security issues or vulnerabilities.
Found 1 instance in 1 package
14579
5
13
309
113
3
3
- Removedglob-promise@1.0.4
- Removed@isaacs/cliui@8.0.2(transitive)
- Removedansi-regex@5.0.16.1.0(transitive)
- Removedansi-styles@4.3.06.2.1(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbrace-expansion@2.0.1(transitive)
- Removedcolor-convert@2.0.1(transitive)
- Removedcolor-name@1.1.4(transitive)
- Removedcross-spawn@7.0.6(transitive)
- Removedeastasianwidth@0.2.0(transitive)
- Removedemoji-regex@8.0.09.2.2(transitive)
- Removedforeground-child@3.3.0(transitive)
- Removedglob@11.0.0(transitive)
- Removedglob-promise@1.0.4(transitive)
- Removedis-fullwidth-code-point@3.0.0(transitive)
- Removedjackspeak@4.0.2(transitive)
- Removedlru-cache@11.0.2(transitive)
- Removedminimatch@10.0.1(transitive)
- Removedminipass@7.1.2(transitive)
- Removedpackage-json-from-dist@1.0.1(transitive)
- Removedpath-key@3.1.1(transitive)
- Removedpath-scurry@2.0.0(transitive)
- Removedshebang-command@2.0.0(transitive)
- Removedshebang-regex@3.0.0(transitive)
- Removedsignal-exit@4.1.0(transitive)
- Removedstring-width@4.2.35.1.2(transitive)
- Removedstrip-ansi@6.0.17.1.0(transitive)
- Removedwhich@2.0.2(transitive)
- Removedwrap-ansi@7.0.08.1.0(transitive)