Comparing version 0.1.2 to 1.0.0
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 @@ } |
{ | ||
"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": { |
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
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
0
13647
7
202