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

npmi

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

npmi - npm Package Compare versions

Comparing version 0.1.2 to 1.0.0

test/test.js

27

npmi.js

@@ -25,3 +25,4 @@ var npm = require('npm');

localInstall = options.localInstall || false,
npmLoad = options.npmLoad || {loglevel: 'silent'};
npmLoad = options.npmLoad || {loglevel: 'silent'},
savedPrefix = null;

@@ -31,2 +32,4 @@ function viewCallback(installedVersion) {

if (err) {
// reset npm.prefix to saved value
npm.prefix = savedPrefix;
err.code = VIEW_ERR;

@@ -39,2 +42,4 @@ return callback(err);

if ((typeof latestVersion !== 'undefined') && (latestVersion === installedVersion)) {
// reset npm.prefix to saved value
npm.prefix = savedPrefix;
return callback();

@@ -81,2 +86,4 @@ } else {

// package is installed and version matches
// reset npm.prefix to saved value
npm.prefix = savedPrefix;
return callback();

@@ -92,9 +99,10 @@

function installCallback(err, result) {
// reset npm.prefix to saved value
npm.prefix = savedPrefix;
if (err) {
err.code = INSTALL_ERR;
return callback(err);
}
// npm installed dependencies from package.json in path successfully
return callback(null, result);
callback(err, result);
}

@@ -109,2 +117,4 @@

// npm loaded successfully
savedPrefix = npm.prefix; // save current npm.prefix
npm.prefix = installPath; // change npm.prefix to given installPath
if (!name) {

@@ -122,2 +132,4 @@ // just want to do an "npm install" where a package.json is

if (err) {
// reset npm.prefix to saved value
npm.prefix = savedPrefix;
callback(err);

@@ -129,5 +141,8 @@

} catch (err) {
// reset npm.prefix to saved value
npm.prefix = savedPrefix;
callback(err);
return;
}
var pkgName = sourcePkg.name || path.basename(name);

@@ -144,2 +159,4 @@ fs.readFile(path.resolve(installPath, 'node_modules', pkgName, 'package.json'), 'utf8', function (err, targetPkgData) {

} catch (err) {
// reset npm.prefix to saved value
npm.prefix = savedPrefix;
callback(err);

@@ -154,2 +171,4 @@ return;

} else {
// reset npm.prefix to saved value
npm.prefix = savedPrefix;
callback();

@@ -156,0 +175,0 @@ }

4

package.json
{
"name": "npmi",
"version": "0.1.2",
"version": "1.0.0",
"description": "Gives a simplier API to npm install (programatically installs stuffs)",
"main": "npmi.js",
"scripts": {
"test": "node test/test.js"
"test": "mocha"
},

@@ -9,0 +9,0 @@ "repository": {

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