Created
April 4, 2016 23:45
-
-
Save dabbott/6842549fe832f814b7e07d5630b4eff5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| const once = require('once') | |
| const fork = require('child_process').fork | |
| class npm { | |
| static run(cmd = [], opts = {}, cb) { | |
| cb = once(cb) | |
| console.log('run npm with', cmd, opts) | |
| var stdout = '' | |
| var stderr = '' | |
| var child = fork('./node_modules/.bin/npm', ['install','deco-ride-share-demo','--save'], opts) | |
| if (child.stderr) { | |
| child.stderr.on('data', function (chunk) { | |
| stderr += chunk | |
| }) | |
| } | |
| if (child.stdout) { | |
| child.stdout.on('data', function (chunk) { | |
| stdout += chunk | |
| }) | |
| } | |
| child.on('error', cb) | |
| child.on('close', function (code) { | |
| cb(null, code, stdout, stderr) | |
| }) | |
| return child | |
| } | |
| } | |
| // npm.run(['install', `${name}@${version}`, '—save'], {cwd: path}, (err) => { | |
| // | |
| // }) | |
| export default npm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment