-
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
7 changed files
with
67 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const exec = require('child_process').exec | ||
const fs = require('fs') | ||
const npmPath = require('npm-path') | ||
const path = require('path') | ||
const spawn = require('child_process').spawn | ||
const which = require('which') | ||
const nm = require('./utils/nm') | ||
|
||
const run = (argv) => { | ||
argv._handled = true | ||
const pkgJSON = require(path.join(process.cwd(), 'package.json')) | ||
const scripts = pkgJSON.scripts | ||
if (argv._.length === 1) { | ||
process.stdout.write( | ||
'Available scripts via `dep run`\n\n' + | ||
Object.keys(scripts).map((key) => { | ||
return 'dep run ' + key + ':\n ' + scripts[key] + '\n' | ||
}).join('\n') + '\n' | ||
) | ||
} else { | ||
var env = {} | ||
var newPath = npmPath.getSync({}) | ||
env[npmPath.PATH] = newPath | ||
const args = argv._.slice(1) | ||
var cmds = scripts[args.shift()] || '' | ||
cmds = cmds.split(' ') | ||
const cmd = cmds.shift() | ||
const script = spawn(cmd, args.concat(cmds), {env: env}) | ||
script.stdout.on('data', (data) => { | ||
process.stdout.write(data) | ||
}) | ||
} | ||
} | ||
|
||
module.exports = { | ||
command: 'run', | ||
describe: 'Run package.json scripts', | ||
handler: run, | ||
aliases: ['r'] | ||
} |
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,12 @@ | ||
const path = require('path') | ||
const exec = require('child_process').exec | ||
const test = require('tap').test | ||
const pkg = path.join(__dirname, 'deps', 'run') | ||
const bin = path.join(__dirname, '..', 'bin', 'dep.js') | ||
|
||
test((t) => { | ||
exec(`node ${bin} run test`, {cwd: pkg}, (err, stdout, stderr) => { | ||
t.ifError(err, 'run test without error') | ||
t.end() | ||
}) | ||
}) |
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,11 @@ | ||
{ | ||
"private": true, | ||
"name": "registry", | ||
"version": "1.0.0", | ||
"scripts": { | ||
"test": "happy-birthday --you=dep" | ||
}, | ||
"dependencies": { | ||
"happy-birthday": "0.6.0" | ||
} | ||
} |