Last active
August 29, 2015 13:56
-
-
Save Mr0grog/9145413 to your computer and use it in GitHub Desktop.
Testing dependencies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
var spawn = require('child_process').spawn; | |
var list = spawn('npm', ['list', '--json']); | |
var result = ""; | |
list.stdout.on('data', function (data) { | |
result += data; | |
}); | |
list.on('close', function(code) { | |
var data = JSON.parse(result); | |
if (data.problems) { | |
data.problems.forEach(function(problem) { | |
console.error(' ' + problem); | |
}); | |
} | |
else { | |
console.log(' Your packages look good!'); | |
} | |
process.exit(code); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "node-test-package", | |
"version": "0.1.0", | |
"description": "Test your your installed packages against your dependencies.", | |
"main": "node-test-package.js", | |
"bin": { | |
"node-test-package": "./node-test-package.js" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "thinger", | |
"version": "0.1.0", | |
"description": "I gots me some bad deps", | |
"main": "index.js", | |
"scripts": { | |
"test": "node_modules/node-test-package/node-test-package.js && run-actual-tests" | |
}, | |
"devDependencies": { | |
"node-test-package": "~0.1.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The incantation that handles my use case seems to be
npm ls --depth=Infinity > /dev/null
. The--depth
argument overrides thenpm_config_depth=null
environment variable that is set up by npm for the test lifecycle.