Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

npm-utils

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

npm-utils - npm Package Compare versions

Comparing version 1.3.1 to 1.3.2

src/get-package.js

3

index.js

@@ -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 @@ }

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