Skip to content

Commit

Permalink
perf(resolve): resolve package.json according to npm version
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieMason committed Apr 19, 2016
1 parent 0934e70 commit eb286a3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 22 deletions.
16 changes: 16 additions & 0 deletions task/lib/isNpm3Up.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 3rd party modules
var childProcess = require('child_process');

// public
module.exports = isNpm3Up;

// implementation
function isNpm3Up () {
return parseFloat(getNpmVersion()) >= 3;
}

function getNpmVersion () {
return childProcess.execSync('npm --version', {
encoding: 'utf8'
}).trim();
}
21 changes: 0 additions & 21 deletions task/resolveTarball/resolveLocally/getPkgPath/index.js

This file was deleted.

6 changes: 5 additions & 1 deletion task/resolveTarball/resolveLocally/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
// modules
var getPkgPath = require('./getPkgPath');
var getNpm2PkgPath = require('./npm2');
var getNpm3PkgPath = require('./npm3');
var isNpm3Up = require('../../lib/isNpm3Up');

// public
module.exports = resolveLocally;

// implementation
var getPkgPath = isNpm3Up() ? getNpm3PkgPath : getNpm2PkgPath;

function resolveLocally (dep) {
return getPkgPath(dep)
.then(function (pkgPath) {
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit eb286a3

Please sign in to comment.