-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
49 additions
and
25 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = (pkg) => { | ||
const scripts = pkg.scripts | ||
process.stdout.write( | ||
'Available scripts via `dep run`\n\n' + | ||
Object.keys(scripts).map((key) => { | ||
return 'dep run ' + key + ':\n ' + scripts[key] | ||
}).join('\n') + '\n' | ||
) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const spawn = require('cross-spawn') | ||
const npmPath = require('npm-path') | ||
const each = require('promise-each') | ||
|
||
module.exports = (_, pkg) => { | ||
const args = _.slice(1) | ||
const scripts = pkg.scripts | ||
const key = args.shift() | ||
var cmds = Object.keys(scripts).filter((script) => { | ||
return script === 'pre' + key | ||
|| script === key | ||
|| script === 'post' + key | ||
}).map((script) => { | ||
return scripts[script].split(' ') | ||
}) | ||
var env = process.env | ||
var newPath = npmPath.getSync({}) | ||
env[npmPath.PATH] = newPath | ||
|
||
Promise.resolve(cmds).then(each((item) => { | ||
return new Promise((resolve, reject) => { | ||
const cmd = item.shift() | ||
const script = spawn(cmd, args.concat(item), {env: env}) | ||
script.stdout.on('data', (data) => { | ||
process.stdout.write(data) | ||
}) | ||
script.stderr.on('data', (data) => { | ||
reject(data) | ||
}) | ||
script.on('close', (data) => { | ||
resolve() | ||
}) | ||
}) | ||
})) | ||
} |