-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
1 parent
91460d7
commit 8004ce4
Showing
46 changed files
with
1,153 additions
and
780 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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
{ | ||
"extends": "mysticatea/nodejs" | ||
"extends": "mysticatea/nodejs", | ||
"rules": { | ||
"require-jsdoc": 2 | ||
} | ||
} |
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 |
---|---|---|
@@ -1,4 +1,8 @@ | ||
/node_modules | ||
/bin | ||
/coverage | ||
/docs | ||
/lib | ||
/node_modules | ||
/npm-debug.log | ||
/test-workspace/npm-debug.log | ||
/test-workspace/test.txt |
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,5 @@ | ||
{ | ||
"source": "src", | ||
"destination": "docs", | ||
"access": ["public", "protected", "private"] | ||
} |
This file was deleted.
Oops, something went wrong.
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,5 @@ | ||
require("babel/register")({ | ||
ignore: /node_modules|test\-workspace/, | ||
optional: ["runtime"], | ||
plugins: ["babel-plugin-espower"] | ||
}); |
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,31 @@ | ||
/** | ||
* @author Toru Nagashima | ||
* @copyright 2015 Toru Nagashima. All rights reserved. | ||
* See LICENSE file in root directory for full license. | ||
*/ | ||
|
||
/** | ||
* Print a help text. | ||
* | ||
* @param {stream.Writable} output - A writable stream to print. | ||
* @returns {Promise} Always a fulfilled promise. | ||
* @private | ||
*/ | ||
export default function printHelp(output) { | ||
output.write(` | ||
Usage: npm-run-all [OPTIONS] [...tasks] | ||
Run specified tasks. | ||
Options: | ||
-h, --help Print this text. | ||
-p, --parallel [...tasks] Run a group of tasks in parallel. | ||
-s, --sequential [...tasks] Run a group of tasks in sequencial. | ||
-v, --version Print version number. | ||
See Also: | ||
https://github.com/mysticatea/npm-run-all#readme | ||
`); | ||
|
||
return Promise.resolve(null); | ||
} |
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,69 @@ | ||
/** | ||
* @author Toru Nagashima | ||
* @copyright 2015 Toru Nagashima. All rights reserved. | ||
* See LICENSE file in root directory for full license. | ||
*/ | ||
import runAll from "../lib/npm-run-all"; | ||
|
||
const START_PROMISE = Promise.resolve(null); | ||
|
||
/** | ||
* Parses arguments. | ||
* | ||
* @param {string[]} args - Arguments to parse. | ||
* @returns {{parallel: boolean, patterns: string[]}[]} A running plan. | ||
*/ | ||
function parse(args) { | ||
return args.reduce((queue, arg) => { | ||
switch (arg) { | ||
case "-s": | ||
case "--sequential": | ||
queue.push({parallel: false, patterns: []}); | ||
break; | ||
|
||
case "-p": | ||
case "--parallel": | ||
queue.push({parallel: true, patterns: []}); | ||
break; | ||
|
||
default: | ||
if (arg[0] === "-") { | ||
throw new Error(`Invalid Option: ${arg}`); | ||
} | ||
queue[queue.length - 1].patterns.push(arg); | ||
break; | ||
} | ||
return queue; | ||
}, [{parallel: false, patterns: []}]); | ||
} | ||
|
||
/** | ||
* Parses arguments, then run specified npm-scripts. | ||
* | ||
* @param {string[]} args - Arguments to parse. | ||
* @param {stream.Writable} stdout - A writable stream to print logs. | ||
* @param {stream.Writable} stderr - A writable stream to print errors. | ||
* @returns {Promise} A promise which comes to be fulfilled when all npm-scripts are completed. | ||
* @private | ||
*/ | ||
export default function npmRunAll(args, stdout, stderr) { | ||
try { | ||
return parse(args).reduce( | ||
(prev, group) => (group.patterns.length === 0) ? | ||
prev : | ||
prev.then(() => runAll( | ||
group.patterns, | ||
{ | ||
stdout, | ||
stderr, | ||
stdin: process.stdin, | ||
parallel: group.parallel | ||
} | ||
)), | ||
START_PROMISE | ||
); | ||
} | ||
catch (err) { | ||
return Promise.reject(err); | ||
} | ||
} |
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,49 @@ | ||
#!/usr/bin/env node | ||
|
||
/** | ||
* @author Toru Nagashima | ||
* @copyright 2015 Toru Nagashima. All rights reserved. | ||
* See LICENSE file in root directory for full license. | ||
*/ | ||
|
||
/** | ||
* The main process of `npm-run-all` command. | ||
* | ||
* @param {string[]} args - Arguments to parse. | ||
* @param {stream.Writable} stdout - A writable stream to print logs. | ||
* @param {stream.Writable} stderr - A writable stream to print errors. | ||
* @returns {Promise} A promise which comes to be fulfilled when all npm-scripts are completed. | ||
* @private | ||
*/ | ||
export default function main( | ||
args, | ||
stdout = null, | ||
stderr = null | ||
) { | ||
switch (args[0]) { | ||
case undefined: | ||
case "-h": | ||
case "--help": | ||
return require("./help")(stdout); | ||
|
||
case "-v": | ||
case "--version": | ||
return require("./version")(stdout); | ||
|
||
default: | ||
return require("./main")(args, stdout, stderr); | ||
} | ||
} | ||
|
||
/* eslint-disable no-process-exit */ | ||
/* istanbul ignore if */ | ||
if (require.main === module) { | ||
// Execute. | ||
const promise = main(process.argv.slice(2), process.stdout, process.stderr); | ||
|
||
// Error Handling. | ||
promise.catch(err => { | ||
console.error("ERROR:", err.message); // eslint-disable-line no-console | ||
process.exit(1); | ||
}); | ||
} |
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 @@ | ||
/** | ||
* @author Toru Nagashima | ||
* @copyright 2015 Toru Nagashima. All rights reserved. | ||
* See LICENSE file in root directory for full license. | ||
*/ | ||
|
||
// In tests, `../../package.json` is correct. | ||
const version = read("../package.json") || read("../../package.json"); | ||
|
||
/** | ||
* Reads the version of `npm-run-all`. | ||
* | ||
* @param {string} path - A path to `package.json`. | ||
* @returns {string|null} A version text. | ||
*/ | ||
function read(path) { | ||
try { | ||
return require(path).version; | ||
} | ||
catch (err) { | ||
return null; | ||
} | ||
} | ||
|
||
/** | ||
* Print a version text. | ||
* | ||
* @param {stream.Writable} output - A writable stream to print. | ||
* @returns {Promise} Always a fulfilled promise. | ||
* @private | ||
*/ | ||
export default function printVersion(output) { | ||
output.write(`v${version}\n`); | ||
return Promise.resolve(null); | ||
} |
Oops, something went wrong.