Program dependency management with node.js
Lately was working with a few PRs for The Yeoman project and tried to hack through a shelljs script to audit the OS before installation.
P.S : npm install shelljs
as this is the dependency for this dependency management script :D
The code :
require('shelljs/global'); var os = require('os'); var sys = require('sys'); var os_type = os.type(); var installed = []; var not_installed = []; var deps = { curl : '', git : '', ruby : '1.8', node : '0.8', compass : '0.12', gem : '', phantomjs : '', jpegtran : '', optipng : '', yeoman : '', clang : '', brew : '' }; if(os_type == "Linux") { //This is Linux so remove Mac deps. delete deps['clang']; delete deps['brew']; } for(var dep in deps) { if (!which(dep)) { not_installed.push(dep); } else{ if(deps[dep]){ var version = exec(dep +' -v', {silent:true}).output; console.log(version); console.log(deps[dep]); if(version.search(deps[dep]) == -1){ not_installed.push(dep); // Installed, but version mismatch. } } else{ installed.push(dep); } } } console.log(installed); console.log(not_installed); Do let me know your thoughts on the same, happy hacking!
Recent blog posts
- watir-webdriver web inspector
- gem list to gemfile
- Packing ruby2.0 on debian.
- Made it into The Guinness Book!
- to_h in ruby 2.0
- Filter elements by pattern jQuery.
- Better HTML password fields for mobile ?
- Grayscale image when user offline
- nth-child CSS pseudo-class Christmas colors
- EventEmitter in nodejs