Skip to content

Commit

Permalink
improve install pkg feature
Browse files Browse the repository at this point in the history
  • Loading branch information
lcxfs1991 committed Jun 23, 2016
1 parent 744f262 commit e724970
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
34 changes: 33 additions & 1 deletion bin/steamer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ const fs = require('fs'),
argv = require('yargs').argv,
exec = require('child_process').exec,
execSync = require('child_process').execSync,
_ = require('lodash');
_ = require('lodash'),
requireg = require('requireg'),
npm = requireg('npm');

const Warning = require('../libs/SteamerErrWarning'),
Logger = require('../libs/SteamerLogger'),
Expand Down Expand Up @@ -149,7 +151,36 @@ function installPkg(paths, projects) {

// let cmd = "nvm use " + nodeVer;
// console.log(execSync(cmd));

let pkgJsonPath = path.join(cwd, 'package.json'),
pgkJsonConfig = {};

if (fs.existsSync(pkgJsonPath)) {
pgkJsonConfig = JSON.parse(fs.readFileSync(pkgJsonPath));
}

console.log(pgkJsonConfig);

npm.load(pkgJsonPath, function (er) {

if (er) {
Logger.error(currentProject + ": \n" + er);
return;
}

npm.commands.install([], function (er, data) {
if (er){
Logger.error(currentProject + ": \n" + er);
}
else {
Logger.log(currentProject + ": \n" + data);
}

});
})

return;

let cmd = "npm i";

let childProcess = exec(cmd, {cwd}, function (error, stdout, stderr) {
Expand All @@ -175,6 +206,7 @@ function installPkg(paths, projects) {
});
};

// console.log(paths);
runNpn(paths[0], 0);
}

Expand Down
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
},
"files": [
"bin",
"libs"
"libs",
"template"
],
"repository": {
"type": "git",
Expand All @@ -27,12 +28,10 @@
},
"homepage": "https://github.com/lcxfs1991/steamer#readme",
"dependencies": {
"gulp": "^3.9.1",
"merge-stream": "^1.0.0",
"lodash": "^4.13.1",
"run-sequence": "^1.2.1",
"yargs": "^4.7.1",
"colors": "^1.1.2"
"colors": "^1.1.2",
"requireg": "^0.1.5"
},
"devDependencies": {

Expand Down

0 comments on commit e724970

Please sign in to comment.