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.1 to 0.1.2

test/foo/anotherPath.js

44

npmi.js

@@ -114,25 +114,35 @@ var npm = require('npm');

// check if there is already a local install of this module
// TODO there is no check made on module integrity => do a shasum integrity check
fs.readFile(path.resolve(installPath, 'node_modules', path.basename(name), 'package.json'), function (err, targetPkgData) {
fs.readFile(path.resolve(name, 'package.json'), 'utf8', function (err, sourcePkgData) {
if (err) {
// file probably doesn't exist, or is corrupted: install
// local install won't work with version specified
npm.commands.install(installPath, [name], installCallback);
callback(err);
} else {
// there is a module that looks a lot like the one you want to install: do some checks
fs.readFile(path.resolve(name, 'package.json'), function (err, sourcePkgData) {
try {
var sourcePkg = JSON.parse(sourcePkgData)
} catch (err) {
callback(err);
return;
}
var pkgName = sourcePkg.name || path.basename(name);
fs.readFile(path.resolve(installPath, 'node_modules', pkgName, 'package.json'), 'utf8', function (err, targetPkgData) {
if (err) {
callback(err);
return;
}
var sourcePkg = JSON.parse(sourcePkgData),
targetPkg = JSON.parse(targetPkgData);
if (semver.gt(sourcePkg.version, targetPkg.version)) {
// install because current found version seems outdated
// file probably doesn't exist, or is corrupted: install
// local install won't work with version specified
npm.commands.install(installPath, [name], installCallback);
} else {
callback();
// there is a module that looks a lot like the one you want to install: do some checks
try {
var targetPkg = JSON.parse(targetPkgData);
} catch (err) {
callback(err);
return;
}
if (semver.gt(sourcePkg.version, targetPkg.version)) {
// install because current found version seems outdated
// local install won't work with version specified
npm.commands.install(installPath, [name], installCallback);
} else {
callback();
}
}

@@ -139,0 +149,0 @@ });

{
"name": "npmi",
"version": "0.1.1",
"version": "0.1.2",
"description": "Gives a simplier API to npm install (programatically installs stuffs)",

@@ -26,5 +26,5 @@ "main": "npmi.js",

"dependencies": {
"npm": "^2.1.5",
"npm": "^2.1.12",
"semver": "^4.1.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