Comparing version 0.1.1 to 0.1.2
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" | ||
} | ||
} |
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
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
14904
14
251
Updatednpm@^2.1.12