amd-tools-cli
Advanced tools
Comparing version 1.0.0-alpha3 to 1.0.0-alpha4
{ | ||
"name": "amd-tools-cli", | ||
"description": "Command-line interface for the amd-tools diagnostic library", | ||
"version": "1.0.0-alpha3", | ||
"version": "1.0.0-alpha4", | ||
"homepage": "https://github.com/zship/amd-tools-cli", | ||
@@ -15,2 +15,5 @@ "author": "Zach Shipley <zach@zachshipley.com>", | ||
}, | ||
"directories": { | ||
"man": "./man" | ||
}, | ||
"preferGlobal": true, | ||
@@ -26,3 +29,4 @@ "dependencies": { | ||
"devDependencies": { | ||
"node-amd-require": "0.x" | ||
"node-amd-require": "0.x", | ||
"ronn": "0.x" | ||
}, | ||
@@ -29,0 +33,0 @@ "keywords": [ |
@@ -40,2 +40,4 @@ 'use strict'; | ||
var hasBrokenDep = false; | ||
filePool.forEach(function(file) { | ||
@@ -48,2 +50,3 @@ var relative = path.relative(process.cwd(), file); | ||
.forEach(function(dep) { | ||
hasBrokenDep = true; | ||
switch(dep.type) { | ||
@@ -66,2 +69,6 @@ case 'plugin': | ||
if (hasBrokenDep) { | ||
log.warn('Circular dependency check may not complete properly due to broken dependencies!'); | ||
} | ||
var cycles = filePool.map(function(file) { | ||
@@ -74,3 +81,3 @@ return findCircularDependencies(file, rjsconfig); | ||
var formatted = cycle.map(function(file) { | ||
return normalize(file, rjsconfig); | ||
return normalize(rjsconfig, file); | ||
}).join(' -> '); | ||
@@ -77,0 +84,0 @@ log.writeln('Circular dependency: [' + formatted + ']'); |
@@ -48,3 +48,3 @@ 'use strict'; | ||
return loop.map(function(file) { | ||
return normalize(file, rjsconfig); | ||
return normalize(rjsconfig, file); | ||
}); | ||
@@ -51,0 +51,0 @@ }); |
@@ -43,3 +43,3 @@ 'use strict'; | ||
deps = deps.map(function(dep) { | ||
return resolve(dep, path.dirname(file), rjsconfig); | ||
return resolve(rjsconfig, path.dirname(file), dep); | ||
}); | ||
@@ -49,3 +49,3 @@ } | ||
deps = deps.map(function(dep) { | ||
return normalize(dep, rjsconfig); | ||
return normalize(rjsconfig, path.dirname(file), dep); | ||
}); | ||
@@ -52,0 +52,0 @@ } |
@@ -22,3 +22,3 @@ 'use strict'; | ||
files.forEach(function(file) { | ||
log.writeln(_normalize(file, rjsconfig)); | ||
log.writeln(_normalize(rjsconfig, file)); | ||
}); | ||
@@ -25,0 +25,0 @@ }; |
@@ -31,3 +31,3 @@ 'use strict'; | ||
var needle = resolve(remain[0], process.cwd(), rjsconfig); | ||
var needle = resolve(rjsconfig, process.cwd(), remain[0]); | ||
var haystack = resolveFileArgs(remain.slice(1), rjsconfig, opts.recursive); | ||
@@ -39,3 +39,3 @@ | ||
var deps = getDependencies(file).map(function(dep) { | ||
return resolve(dep, path.dirname(file), rjsconfig); | ||
return resolve(rjsconfig, path.dirname(file), dep); | ||
}); | ||
@@ -42,0 +42,0 @@ |
'use strict'; | ||
var path = require('path'); | ||
var child = require('child_process'); | ||
var glob = require('glob'); | ||
var Levenshtein = require('levenshtein'); | ||
@@ -8,9 +12,11 @@ | ||
var parseOpts = require('./util/parseOpts'); | ||
var deplist = require('./amd-tools-deplist'); | ||
var normalize = require('./amd-tools-normalize'); | ||
var resolve = require('./amd-tools-resolve'); | ||
var check = require('./amd-tools-check'); | ||
var whatrequires = require('./amd-tools-whatrequires'); | ||
var scripts = {}; | ||
glob.sync(__dirname + '/**/amd-tools-*.js').forEach(function(file) { | ||
var name = file.replace(/.*\/amd\-tools\-(\S*)\.js/, '$1'); | ||
scripts[name] = file; | ||
}); | ||
var cli = function() { | ||
@@ -31,36 +37,36 @@ | ||
switch(task) { | ||
case 'resolve': | ||
resolve(); | ||
break; | ||
case 'normalize': | ||
normalize(); | ||
break; | ||
case 'check': | ||
check(); | ||
break; | ||
case 'deplist': | ||
deplist(); | ||
break; | ||
case 'whatrequires': | ||
whatrequires(); | ||
break; | ||
default: | ||
log.error('amd-tools: \'' + task + '\' is not an amd-tools command.'); | ||
var suggest = []; | ||
['resolve', 'id', 'check', 'deplist', 'whatrequires'].forEach(function(cmd) { | ||
var l = new Levenshtein(task, cmd).distance; | ||
if (l < 5) { | ||
suggest.push(cmd); | ||
} | ||
if (task === 'help') { | ||
var term = opts.argv.remain[0]; | ||
var manpath = path.join(__dirname, '..', 'man'); | ||
if (term) { | ||
manpath = path.join(manpath, 'amd-tools-' + term + '.1'); | ||
} | ||
else { | ||
manpath = path.join(manpath, 'amd-tools.1'); | ||
} | ||
var conf = { customFds: [0, 1, 2] }; | ||
var man = child.spawn('man', [manpath], conf); | ||
man.on('close', function() {}); | ||
} | ||
if (Object.keys(scripts).indexOf(task) === -1) { | ||
log.error('amd-tools: \'' + task + '\' is not an amd-tools command.'); | ||
var suggest = []; | ||
Object.keys(scripts).forEach(function(cmd) { | ||
var l = new Levenshtein(task, cmd).distance; | ||
if (l < 5) { | ||
suggest.push(cmd); | ||
} | ||
}); | ||
if (suggest.length) { | ||
log.error('\nDid you mean:'); | ||
suggest.forEach(function(sugg) { | ||
log.error(' ' + sugg); | ||
}); | ||
if (suggest.length) { | ||
log.error('\nDid you mean:'); | ||
suggest.forEach(function(sugg) { | ||
log.error(' ' + sugg); | ||
}); | ||
} | ||
break; | ||
} | ||
return; | ||
} | ||
require(scripts[task])(); | ||
}; | ||
@@ -67,0 +73,0 @@ |
@@ -47,3 +47,3 @@ 'use strict'; | ||
files = files.map(function(file) { | ||
var resolved = resolve(file, process.cwd(), rjsconfig); | ||
var resolved = resolve(rjsconfig, process.cwd(), file); | ||
if (!resolved || !fs.existsSync(resolved)) { | ||
@@ -50,0 +50,0 @@ log.warn('"' + file + '" could not be resolved.'); |
Sorry, the diff of this file is not supported yet
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
34275
904
2
17
4
1