Template Upload

This commit is contained in:
SOUTHERNCO\x2mjbyrn
2017-05-17 13:45:25 -04:00
parent 415b9c25f3
commit 7efe7605b8
11476 changed files with 2170865 additions and 34 deletions

28
node_modules/concurrently/.editorconfig generated vendored Normal file
View File

@ -0,0 +1,28 @@
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
# 4 space indentation
[*.py]
indent_style = space
indent_size = 4
# Tab indentation (no size specified)
[*.js]
indent_style = space
indent_size = 4
# Matches the exact files package.json and .travis.yml
[{package.json,.travis.yml,Gruntfile.js}]
indent_style = space
indent_size = 2
[Makefile]
indent_style = tab
indent_size = 4

17
node_modules/concurrently/.jshintrc generated vendored Normal file
View File

@ -0,0 +1,17 @@
{
"node": true,
"browser": true,
"predef": [ "Promise" ],
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 4,
"latedef": false,
"newcap": true,
"noarg": true,
"quotmark": "single",
"regexp": true,
"devel": true
}

31
node_modules/concurrently/.npmignore generated vendored Normal file
View File

@ -0,0 +1,31 @@
# Logs
logs
*.log
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directory
# Deployed apps should consider commenting this line out:
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
node_modules
# OS X
.DS_Store
# Vagrant directory
.vagrant

9
node_modules/concurrently/.travis.yml generated vendored Normal file
View File

@ -0,0 +1,9 @@
language: node_js
node_js:
- '0.12'
- '0.11'
before_script:
- npm install -g mocha
notifications:
email:
- kimmobrunfeldt+concurrent@gmail.com

28
node_modules/concurrently/CONTRIBUTING.md generated vendored Normal file
View File

@ -0,0 +1,28 @@
# Contributing
Pull requests and contributions are warmly welcome.
Please follow existing code style and commit message conventions. Also remember to keep documentation
updated.
**Pull requests:** You don't need to bump version numbers or modify anything related to releasing. That stuff is fully automated, just write the functionality.
# Maintaining
## Test
Tests can be run with command:
```bash
mocha
```
You need to have *mocha* installed globally with `npm install -g mocha`.
## Release
* Commit all changes
* Run `./tools/release.js minor`, which will create new tag and publish code to GitHub and npm
* Edit GitHub release notes

21
node_modules/concurrently/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015 Kimmo Brunfeldt
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

122
node_modules/concurrently/README.md generated vendored Normal file
View File

@ -0,0 +1,122 @@
# Concurrently
[![Build Status](https://travis-ci.org/kimmobrunfeldt/concurrently.svg)](https://travis-ci.org/kimmobrunfeldt/concurrently)
**Version: 2.2.0** ([*previous stable*](https://github.com/kimmobrunfeldt/concurrently/tree/2.1.0))
Run multiple commands concurrently.
Like `npm run watch-js & npm run watch-less` but better.
![](docs/demo.gif)
**Features:**
* Cross platform, works also in Windows
* Output is easy to follow with prefixes
* With `--kill-others` switch, all commands are killed if one dies
## Install
The tool is written in Node.js, but you can use it to run **any** commands.
```bash
npm install -g concurrently
```
## Usage
Remember to surround separate commands with quotes, like this:
```bash
concurrently "command1 arg" "command2 arg"
```
Otherwise **concurrently** would try to run 4 separate commands:
`command1`, `arg`, `command2`, `arg`.
Help:
```
Usage: concurrently [options] <command ...>
Options:
-h, --help output usage information
-V, --version output the version number
-k, --kill-others kill other processes if one exits or dies
--no-color disable colors from logging
--names names different processes, i.e --name "web,api,hot-server" to be used in the prefix switch
-p, --prefix <prefix> prefix used in logging for each process.
Possible values: index, pid, time, command, name, none or a template. Default: index. Example template "{time}-{pid}"
-tf, --timestamp-format <format> specify the timestamp in moment format. Default: YYYY-MM-DD HH:mm:ss.SSS
-r, --raw output only raw output of processes, disables prettifying and concurrently coloring
-s, --success <first|last|all> Return exit code of zero or one based on the success or failure of the "first" child to terminate, the "last" child, or succeed only if "all" child processes succeed. Default: all
-l, --prefix-length <length> limit how many characters of the command is displayed in prefix.
The option can be used to shorten long commands.
Works only if prefix is set to "command". Default: 10
Examples:
- Kill other processes if one exits or dies
$ concurrently --kill-others "grunt watch" "http-server"
- Output nothing more than stdout+stderr of child processes
$ concurrently --raw "npm run watch-less" "npm run watch-js"
- Normal output but without colors e.g. when logging to file
$ concurrently --no-color "grunt watch" "http-server" > log
- Custom prefix
$ concurrently --prefix "{time}-{pid}" "grunt watch" "http-server"
For more details, visit https://github.com/kimmobrunfeldt/concurrently
```
## FAQ
* Process exited with code *null*?
From [Node child_process documentation](http://nodejs.org/api/child_process.html#child_process_event_exit), `exit` event:
> This event is emitted after the child process ends. If the process
> terminated normally, code is the final exit code of the process,
> otherwise null. If the process terminated due to receipt of a signal,
> signal is the string name of the signal, otherwise null.
So *null* means the process didn't terminate normally. This will make **concurrent**
to return non-zero exit code too.
## Why
I like [task automation with npm](http://substack.net/task_automation_with_npm_run)
but the usual way to run multiple commands concurrently is
`npm run watch-js & npm run watch-css`. That's fine but it's hard to keep
on track of different outputs. Also if one process fails, others still keep running
and you won't even notice the difference.
Another option would be to just run all commands in separate terminals. I got
tired of opening terminals and made **concurrently**.
### NPM Issue
Previously I thought this could fix some problems I had with watching scripts and this readme said:
> When running watch or serve tasks, I'd recommend to use `--kill-others` option:
>
> ```bash
> concurrently --kill-others "npm run watch-js" "npm run watch-less"
> ```
>
> That way, if for some reason e.g. your `watch-less` died, you would notice it easier.
However NPM didn't work as I hoped it would. See [this issue](https://github.com/kimmobrunfeldt/concurrently/issues/4).

BIN
node_modules/concurrently/docs/demo.gif generated vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

102
node_modules/concurrently/package.json generated vendored Normal file
View File

@ -0,0 +1,102 @@
{
"_args": [
[
"concurrently@^2.0.0",
"C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton"
]
],
"_from": "concurrently@>=2.0.0-0 <3.0.0-0",
"_id": "concurrently@2.2.0",
"_inCache": true,
"_location": "/concurrently",
"_nodeVersion": "6.1.0",
"_npmOperationalInternal": {
"host": "packages-12-west.internal.npmjs.com",
"tmp": "tmp/concurrently-2.2.0.tgz_1467712409992_0.07769871852360666"
},
"_npmUser": {
"email": "kimmo.brunfeldt@gmail.com",
"name": "kimmobrunfeldt"
},
"_npmVersion": "3.8.6",
"_phantomChildren": {},
"_requested": {
"name": "concurrently",
"raw": "concurrently@^2.0.0",
"rawSpec": "^2.0.0",
"scope": null,
"spec": ">=2.0.0-0 <3.0.0-0",
"type": "range"
},
"_requiredBy": [
"#DEV:/"
],
"_resolved": "https://registry.npmjs.org/concurrently/-/concurrently-2.2.0.tgz",
"_shasum": "bad248e0bb129fb1621768903a6311d45d56895a",
"_shrinkwrap": null,
"_spec": "concurrently@^2.0.0",
"_where": "C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton",
"author": {
"name": "Kimmo Brunfeldt"
},
"bin": {
"concurrent": "./src/main.js",
"concurrently": "./src/main.js"
},
"bugs": {
"url": "https://github.com/kimmobrunfeldt/concurrently/issues"
},
"dependencies": {
"bluebird": "2.9.6",
"chalk": "0.5.1",
"commander": "2.6.0",
"cross-spawn": "^0.2.9",
"lodash": "^4.5.1",
"moment": "^2.11.2",
"rx": "2.3.24"
},
"description": "Run commands concurrently",
"devDependencies": {
"chai": "^1.10.0",
"mocha": "^2.1.0",
"mustache": "^1.0.0",
"semver": "^4.2.0",
"shell-quote": "^1.4.3",
"shelljs": "^0.3.0",
"string": "^3.0.0"
},
"directories": {},
"dist": {
"shasum": "bad248e0bb129fb1621768903a6311d45d56895a",
"tarball": "https://registry.npmjs.org/concurrently/-/concurrently-2.2.0.tgz"
},
"gitHead": "497a6c35a19df981ba67430feb7f8612ab0bfd29",
"homepage": "https://github.com/kimmobrunfeldt/concurrently",
"installable": true,
"keywords": [
"bash",
"command",
"concurrent",
"concurrently",
"parallel",
"sh"
],
"license": "MIT",
"main": "src/main.js",
"maintainers": [
{
"name": "kimmobrunfeldt",
"email": "kimmo.brunfeldt@gmail.com"
}
],
"name": "concurrently",
"optionalDependencies": {},
"repository": {
"type": "git",
"url": "git+https://github.com/kimmobrunfeldt/concurrently.git"
},
"scripts": {
"test": "mocha"
},
"version": "2.2.0"
}

443
node_modules/concurrently/src/main.js generated vendored Normal file
View File

@ -0,0 +1,443 @@
#!/usr/bin/env node
var Rx = require('rx');
var path = require('path');
var Promise = require('bluebird');
var moment = require('moment');
var program = require('commander');
var _ = require('lodash');
var chalk = require('chalk');
var spawn = Promise.promisifyAll(require('cross-spawn'));
var isWindows = /^win/.test(process.platform);
var config = {
// Kill other processes if one dies
killOthers: false,
// How much in ms we wait before killing other processes
killDelay: 1000,
// Return success or failure of the 'first' child to terminate, the 'last' child,
// or succeed only if 'all' children succeed
success: 'all',
// Prefix logging with pid
// Possible values: 'pid', 'none', 'time', 'command', 'index', 'name'
prefix: 'index',
// List of custom names to be used in prefix template
names: '',
// What to split the list of custom names on
nameSeparator: ',',
// Comma-separated list of chalk color paths to use on prefixes.
prefixColors: 'gray.dim',
// moment format
timestampFormat: 'YYYY-MM-DD HH:mm:ss.SSS',
// How many characters to display from start of command in prefix if
// command is defined. Note that also '..' will be added in the middle
prefixLength: 10,
// By default, color output
color: true,
// If true, the output will only be raw output of processes, nothing more
raw: false
};
function main() {
var firstBase = path.basename(process.argv[0]);
var secondBase = path.basename(process.argv[1]);
if (firstBase === 'concurrent' || secondBase === 'concurrent') {
console.error('"concurrent" command is deprecated, use "concurrently" instead.\n');
}
parseArgs();
config = mergeDefaultsWithArgs(config);
run(program.args);
}
function parseArgs() {
program
.version(require('../package.json').version)
.usage('[options] <command ...>')
.option(
'-k, --kill-others',
'kill other processes if one exits or dies'
)
.option(
'--no-color',
'disable colors from logging'
)
.option(
'-p, --prefix <prefix>',
'prefix used in logging for each process.\n' +
'Possible values: index, pid, time, command, name, none, or a template. Default: ' +
config.prefix + '. Example template: "{time}-{pid}"\n'
)
.option(
'-n, --names <names>',
'List of custom names to be used in prefix template.\n' +
'Example names: "main,browser,server"\n'
)
.option(
'--name-separator <char>',
'The character to split <names> on.\n' +
'Default: "' + config.nameSeparator + '". Example usage: ' +
'concurrently -n "styles,scripts|server" --name-separator "|" <command ...>\n'
)
.option(
'-c, --prefix-colors <colors>',
'Comma-separated list of chalk colors to use on prefixes. If there are more commands than colors, the last color will be repeated.\n' +
'Available modifiers: reset, bold, dim, italic, underline, inverse, hidden, strikethrough\n' +
'Available colors: black, red, green, yellow, blue, magenta, cyan, white, gray\n' +
'Available background colors: bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite\n' +
'See https://www.npmjs.com/package/chalk for more information.\n' +
'Default: "' + config.prefixColors + '". Example: "black.bgWhite,cyan,gray.dim"\n'
)
.option(
'-t, --timestamp-format <format>',
'specify the timestamp in moment format. Default: ' +
config.timestampFormat + '\n'
)
.option(
'-r, --raw',
'output only raw output of processes,' +
' disables prettifying and concurrently coloring'
)
.option(
'-s, --success <first|last|all>',
'Return exit code of zero or one based on the success or failure ' +
'of the "first" child to terminate, the "last" child, or succeed ' +
' only if "all" child processes succeed. Default: ' +
config.success + '\n'
)
.option(
'-l, --prefix-length <length>',
'limit how many characters of the command is displayed in prefix.\n' +
'The option can be used to shorten long commands.\n' +
'Works only if prefix is set to "command". Default: ' +
config.prefixLength + '\n'
);
program.on('--help', function() {
var help = [
' Examples:',
'',
' - Kill other processes if one exits or dies',
'',
' $ concurrently --kill-others "grunt watch" "http-server"',
'',
' - Output nothing more than stdout+stderr of child processes',
'',
' $ concurrently --raw "npm run watch-less" "npm run watch-js"',
'',
' - Normal output but without colors e.g. when logging to file',
'',
' $ concurrently --no-color "grunt watch" "http-server" > log',
'',
' - Custom prefix',
'',
' $ concurrently --prefix "{time}-{pid}" "grunt watch" "http-server"',
''
];
console.log(help.join('\n'));
var url = 'https://github.com/kimmobrunfeldt/concurrently';
console.log(' For more details, visit ' + url);
console.log('');
});
program.parse(process.argv);
}
function mergeDefaultsWithArgs(config) {
// This will pollute config object with other attributes from program too
return _.merge(config, program);
}
function stripCmdQuotes(cmd) {
// Removes the quotes surrounding a command.
if (cmd[0] === '"' || cmd[0] === '\'') {
return cmd.substr(1, cmd.length - 2);
} else {
return cmd;
}
}
function separateCmdArgs(cmd) {
// We're splitting up the command into space-separated parts.
// The first item is the command, all remaining items are the
// arguments. To permit commands with spaces in the name
// (or directory name), double slashes is a usable escape sequence.
var escape = cmd.search('\\\s'),
divide = cmd.search(/[^\\]\s/),
path, args, parts;
if (escape === -1) {
// Not an escaped path. Most common case.
parts = cmd.split(' ');
} else if (escape > -1 && divide === -1) {
// Escaped path without arguments.
parts = [cmd.replace('\\ ', ' ')];
} else {
// Escaped path with arguments.
path = cmd.substr(0, divide + 1).replace('\\ ', ' ');
args = cmd.substr(divide + 1).split(' ').filter(function(part) {
return part.trim() != '';
});
parts = [path].concat(args);
}
// Parts contains the command as the first item and any arguments
// as subsequent items.
return parts;
}
function run(commands) {
var childrenInfo = {};
var lastPrefixColor = _.get(chalk, chalk.gray.dim);
var prefixColors = config.prefixColors.split(',');
var names = config.names.split(config.nameSeparator);
var children = _.map(commands, function(cmd, index) {
// Remove quotes.
cmd = stripCmdQuotes(cmd);
// Split the command up in the command path and its arguments.
var parts = separateCmdArgs(cmd);
var spawnOpts = config.raw ? {stdio: 'inherit'} : {};
if (isWindows) {
spawnOpts.detached = false;
}
var child;
try {
child = spawn(_.head(parts), _.tail(parts), spawnOpts);
} catch (e) {
logError('', chalk.gray.dim, 'Error occured when executing command: ' + cmd);
logError('', chalk.gray.dim, e.stack);
process.exit(1);
}
if (index < prefixColors.length) {
var prefixColorPath = prefixColors[index];
lastPrefixColor = _.get(chalk, prefixColorPath);
}
var name = index < names.length ? names[index] : '';
childrenInfo[child.pid] = {
command: cmd,
index: index,
name: name,
prefixColor: lastPrefixColor
};
return child;
});
// Transform all process events to rx streams
var streams = _.map(children, function(child) {
var childStreams = {
error: Rx.Node.fromEvent(child, 'error'),
close: Rx.Node.fromEvent(child, 'close')
};
if (!config.raw) {
childStreams.stdout = Rx.Node.fromReadableStream(child.stdout);
childStreams.stderr = Rx.Node.fromReadableStream(child.stderr);
}
return _.reduce(childStreams, function(memo, stream, key) {
memo[key] = stream.map(function(data) {
return {child: child, data: data};
});
return memo;
}, {});
});
handleClose(streams, children, childrenInfo);
handleError(streams, childrenInfo);
if (!config.raw) {
handleOutput(streams, childrenInfo, 'stdout');
handleOutput(streams, childrenInfo, 'stderr');
}
}
function handleOutput(streams, childrenInfo, source) {
var sourceStreams = _.map(streams, source);
var combinedSourceStream = Rx.Observable.merge.apply(this, sourceStreams);
combinedSourceStream.subscribe(function(event) {
var prefix = getPrefix(childrenInfo, event.child);
var prefixColor = childrenInfo[event.child.pid].prefixColor;
log(prefix, prefixColor, event.data.toString());
});
}
function handleClose(streams, children, childrenInfo) {
var aliveChildren = _.clone(children);
var exitCodes = [];
var closeStreams = _.map(streams, 'close');
var closeStream = Rx.Observable.merge.apply(this, closeStreams);
// TODO: Is it possible that amount of close events !== count of spawned?
closeStream.subscribe(function(event) {
var exitCode = event.data;
exitCodes.push(exitCode);
var prefix = getPrefix(childrenInfo, event.child);
var prefixColor = childrenInfo[event.child.pid].prefixColor;
var command = childrenInfo[event.child.pid].command;
logEvent(prefix, prefixColor, command + ' exited with code ' + exitCode);
aliveChildren = _.filter(aliveChildren, function(child) {
return child.pid !== event.child.pid;
});
if (aliveChildren.length === 0) {
exit(exitCodes);
}
});
if (config.killOthers) {
// Give other processes some time to stop cleanly before killing them
var delayedExit = closeStream.delay(config.killDelay);
delayedExit.subscribe(function() {
logEvent('--> ', chalk.gray.dim, 'Sending SIGTERM to other processes..');
// Send SIGTERM to alive children
_.each(aliveChildren, function(child) {
if (isWindows) {
spawn('taskkill', ["/pid", child.pid, '/f', '/t']);
} else {
child.kill('SIGINT');
}
});
});
}
}
function exit(childExitCodes) {
var success;
switch (config.success) {
case 'first':
success = _.first(childExitCodes) === 0;
break;
case 'last':
success = _.last(childExitCodes) === 0;
break;
default:
success = _.every(childExitCodes, function(code) {
return code === 0;
});
}
process.exit(success ? 0 : 1);
}
function handleError(streams, childrenInfo) {
// Output emitted errors from child process
var errorStreams = _.map(streams, 'error');
var processErrorStream = Rx.Observable.merge.apply(this, errorStreams);
processErrorStream.subscribe(function(event) {
var command = childrenInfo[event.child.pid].command;
logError('', chalk.gray.dim, 'Error occured when executing command: ' + command);
logError('', chalk.gray.dim, event.data.stack);
});
}
function colorText(text, color) {
if (!config.color) {
return text;
} else {
return color(text);
}
}
function getPrefix(childrenInfo, child) {
var prefixes = getPrefixes(childrenInfo, child);
if (_.includes(_.keys(prefixes), config.prefix)) {
return '[' + prefixes[config.prefix] + '] ';
}
return _.reduce(prefixes, function(memo, val, key) {
var re = new RegExp('{' + key + '}', 'g');
return memo.replace(re, val);
}, config.prefix) + ' ';
}
function getPrefixes(childrenInfo, child) {
var prefixes = {};
prefixes.none = '';
prefixes.pid = child.pid;
prefixes.index = childrenInfo[child.pid].index;
prefixes.name = childrenInfo[child.pid].name;
prefixes.time = moment().format(config.timestampFormat);
var command = childrenInfo[child.pid].command;
prefixes.command = shortenText(command, config.prefixLength);
return prefixes;
}
function shortenText(text, length, cut) {
if (text.length <= length) {
return text;
}
cut = _.isString(cut) ? cut : '..';
var endLength = Math.floor(length / 2);
var startLength = length - endLength;
var first = text.substring(0, startLength);
var last = text.substring(text.length - endLength, text.length);
return first + cut + last;
}
function log(prefix, prefixColor, text) {
logWithPrefix(prefix, prefixColor, text);
}
function logEvent(prefix, prefixColor, text) {
if (config.raw) return;
logWithPrefix(prefix, prefixColor, text, chalk.gray.dim);
}
function logError(prefix, prefixColor, text) {
// This is for now same as log, there might be separate colors for stderr
// and stdout
logWithPrefix(prefix, prefixColor, text, chalk.red.bold);
}
function logWithPrefix(prefix, prefixColor, text, color) {
var lastChar = text[text.length - 1];
if (config.raw) {
if (lastChar !== '\n') {
text += '\n';
}
process.stdout.write(text);
return;
}
if (lastChar === '\n') {
// Remove extra newline from the end to prevent extra newlines in input
text = text.slice(0, text.length - 1);
}
var lines = text.split('\n');
// Do not bgColor trailing space
var coloredPrefix = colorText(prefix.replace(/ $/, ''), prefixColor) + ' ';
var paddedLines = _.map(lines, function(line, i) {
var coloredLine = color ? colorText(line, color) : line;
return coloredPrefix + coloredLine;
});
console.log(paddedLines.join('\n'));
}
main();

7
node_modules/concurrently/test.js generated vendored Normal file
View File

@ -0,0 +1,7 @@
var chalk = require('chalk');
// style a string
console.log(chalk.blue('Hello world!'));
// combine styled and normal strings
console.log(chalk.blue('Hello') + 'World' + chalk.red('!'));

83
node_modules/concurrently/test/test-functional.js generated vendored Normal file
View File

@ -0,0 +1,83 @@
// Test basic usage of cli
var path = require('path');
var assert = require('assert');
var run = require('./utils').run;
// If true, output of commands are shown
var DEBUG_TESTS = false;
var TEST_DIR = 'dir/';
// Abs path to test directory
var testDir = path.resolve(__dirname);
process.chdir(path.join(testDir, '..'));
describe('concurrently', function() {
this.timeout(5000);
it('help should be successful', function(done) {
run('node ./src/main.js --help', {pipe: DEBUG_TESTS})
.then(function(exitCode) {
// exit code 0 means success
assert.strictEqual(exitCode, 0);
done();
});
});
it('version should be successful', function(done) {
run('node ./src/main.js -V', {pipe: DEBUG_TESTS})
.then(function(exitCode) {
assert.strictEqual(exitCode, 0);
done();
});
});
it('two successful commands should exit 0', function(done) {
run('node ./src/main.js "echo" "echo"', {pipe: DEBUG_TESTS})
.then(function(exitCode) {
assert.strictEqual(exitCode, 0);
done();
});
});
it('at least one unsuccessful commands should exit non-zero', function(done) {
run('node ./src/main.js "echo" "return 1" "echo"', {pipe: DEBUG_TESTS})
.then(function(exitCode) {
assert.notStrictEqual(exitCode, 0);
done();
});
});
it('--kill-others should kill other commands if one dies', function(done) {
// This test would timeout if kill others option does not work
run('node ./src/main.js --kill-others "sleep 1000" "echo" "sleep 1000"', {pipe: DEBUG_TESTS})
.then(function(exitCode) {
assert.notStrictEqual(exitCode, 0);
done();
});
});
it('--success=first should return first exit code', function(done) {
run('node ./src/main.js -k --success first "echo" "sleep 1000" ', {pipe: DEBUG_TESTS})
// When killed, sleep returns null exit code
.then(function(exitCode) {
assert.strictEqual(exitCode, 0);
done();
});
});
it('--success=last should return last exit code', function(done) {
// When killed, sleep returns null exit code
run('node ./src/main.js -k --success last "echo" "sleep 1000" ', {pipe: DEBUG_TESTS})
.then(function(exitCode) {
assert.notStrictEqual(exitCode, 0);
done();
});
});
});
function resolve(relativePath) {
return path.join(testDir, relativePath);
}

44
node_modules/concurrently/test/utils.js generated vendored Normal file
View File

@ -0,0 +1,44 @@
var childProcess = require('child_process');
var _ = require('lodash');
var Promise = require('bluebird');
var shellQuote = require('shell-quote');
function run(cmd, opts) {
opts = _.merge({
pipe: true,
cwd: undefined,
callback: function(child) {
// Since we return promise, we need to provide
// this callback if one wants to access the child
// process reference
// Called immediately after successful child process
// spawn
}
}, opts);
var child;
var parts = shellQuote.parse(cmd);
try {
child = childProcess.spawn(_.head(parts), _.tail(parts), {
cwd: opts.cwd,
stdio: opts.pipe ? "inherit" : null
});
} catch (e) {
return Promise.reject(e);
}
opts.callback(child);
return new Promise(function(resolve, reject) {
child.on('error', function(err) {
reject(err);
});
child.on('close', function(exitCode) {
resolve(exitCode);
});
});
}
module.exports = {
run: run
};

273
node_modules/concurrently/tools/release.js generated vendored Normal file
View File

@ -0,0 +1,273 @@
#!/usr/bin/env node
// Release automation script inspired by
// https://github.com/geddski/grunt-release
var fs = require('fs');
var path = require('path');
var _ = require('lodash');
var S = require('string');
var shell = require('shelljs');
var Mustache = require('mustache');
var semver = require('semver');
var program = require('commander');
var Promise = require('bluebird');
// Message templates use https://github.com/janl/mustache.js
var config = {
releaseMessage: 'Release {{ version }}',
backToDevMessage: 'Bump to dev version',
bumpType: 'patch',
files: ['package.json'],
readmeFile: 'README.md',
indentation: 4,
// If true, don't execute anything, just tell what would have been done
dryRun: false,
// If true, don't push commits/tags or release to npm
noPush: false,
consolePrefix: '->',
devSuffix: '-dev'
};
var projectRoot = path.join(__dirname, '..');
process.chdir(projectRoot);
function main() {
parseArgs();
config = mergeArgsToDefaults(config);
if (config.dryRun) status('Dry run\n');
var newVersion = bumpVersion(config.files, config.bumpType);
_gitBranchName()
.then(function(stdout) {
if (stdout.trim().toLowerCase() !== 'master') {
throw new Error('You should be in master branch before running the script!');
}
return gitAdd([config.readmeFile]);
})
.then(function() {
return gitAdd(config.files);
})
.then(function() {
var message = Mustache.render(config.releaseMessage, {
version: newVersion
});
return gitCommit(message);
})
.then(function() {
return gitTag(newVersion);
})
.then(function() {
return gitPushTag(newVersion);
})
.then(npmPublish)
.then(function() {
bumpVersion(config.files, 'dev');
return gitAdd(config.files.concat(config.readmeFile));
})
.then(function() {
return gitCommit(config.backToDevMessage);
})
.then(function() {
gitPush();
})
.then(function() {
console.log('');
status('Release successfully done!');
})
.catch(function(err) {
console.error('\n!! Releasing failed');
console.trace(err);
process.exit(2);
});
}
function parseArgs() {
program
.usage('bump');
program.on('--help', function() {
console.log(' Example usage:');
console.log('');
console.log(' $ ./release.js minor');
});
program.parse(process.argv);
}
function mergeArgsToDefaults(config) {
if (program.args[0]) {
config.bumpType = program.args[0];
if (!_.includes(['major', 'minor', 'patch'], config.bumpType)) {
console.error('Error:', config.bumpType, 'is not a valid bump type');
process.exit(1);
}
}
return config;
}
function status( /* arguments */ ) {
var args = Array.prototype.slice.call(arguments);
console.log(config.consolePrefix, args.join(' '));
}
function run(cmd, msg) {
// All calls are actually synchronous but eventually some task
// will need async stuff, so keep them promises
return new Promise(function(resolve, reject) {
if (msg) {
status(msg);
}
if (config.dryRun) {
return resolve();
}
var exec = shell.exec(cmd);
var success = exec.code === 0;
if (success) {
resolve(exec.output);
} else {
var errMsg = 'Error executing: `' + cmd + '`\nOutput:\n' + exec.output;
var err = new Error(errMsg);
reject(err);
}
});
}
// Task functions
// All functions should return promise
// Bumps version in specified files.
// Files are assumed to contain JSON data which has "version" key following
// semantic versioning
function bumpVersion(files, bumpType) {
status('Bump', bumpType, 'version to files:', files.join(' '));
if (config.dryRun) return '[not available in dry run]';
var newVersion;
var originalVersion;
files.forEach(function(fileName) {
var filePath = path.join(projectRoot, fileName);
var data = JSON.parse(fs.readFileSync(filePath));
originalVersion = data.version;
var currentVersion = data.version;
if (!semver.valid(currentVersion)) {
var msg = 'Invalid version ' + currentVersion +
' in file ' + fileName;
var err = new Error(msg);
throw err;
}
if (S(currentVersion).endsWith(config.devSuffix)) {
currentVersion = S(currentVersion).chompRight(config.devSuffix).s;
}
if (bumpType === 'dev') {
newVersion = currentVersion + config.devSuffix;
} else {
newVersion = semver.inc(currentVersion, bumpType);
}
data.version = newVersion;
var content = JSON.stringify(data, null, config.indentation);
fs.writeFileSync(filePath, content);
status('Bump', originalVersion, '->', newVersion, 'in',
fileName);
});
bumpReadmeVersion(originalVersion, newVersion, bumpType);
return newVersion;
}
function bumpReadmeVersion(oldVersion, newVersion, bumpType) {
if (bumpType === 'dev') {
// Don't bump readme version in to dev version
return;
}
var oldReleaseVersion = oldVersion;
if (S(oldReleaseVersion).endsWith(config.devSuffix)) {
oldReleaseVersion = S(oldReleaseVersion).chompRight(config.devSuffix).s;
}
status('Replace readme version', oldReleaseVersion, '->', newVersion);
if (config.dryRun) return;
var filePath = path.join(projectRoot, config.readmeFile);
var content = fs.readFileSync(filePath, {encoding: 'utf-8'});
// Update visible version
var re = new RegExp('Version: ' + oldReleaseVersion, 'g');
var newContent = content.replace(re, 'Version: ' + newVersion);
// Replace link to previous stable
re = new RegExp('tree/[0-9]\\.[0-9]\\.[0-9]');
newContent = newContent.replace(re, 'tree/' + oldReleaseVersion);
fs.writeFileSync(filePath, newContent);
}
function gitAdd(files) {
var cmd = 'git add ' + files.join(' ');
var msg = 'Staged ' + files.length + ' files';
return run(cmd, msg);
}
function gitCommit(message) {
var cmd = 'git commit -m "' + message + '"';
var msg = 'Commit files';
return run(cmd, msg);
}
function gitTag(name) {
var cmd = 'git tag ' + name;
var msg = 'Created a new git tag: ' + name;
return run(cmd, msg);
}
function gitPush() {
if (config.noPush) return;
var cmd = 'git push';
var msg = 'Push to remote';
return run(cmd, msg);
}
function gitPushTag(tagName) {
if (config.noPush) return;
var cmd = 'git push origin ' + tagName;
var msg = 'Push created git tag to remote';
return run(cmd, msg);
}
function npmPublish() {
if (config.noPush) return;
var cmd = 'npm publish';
var msg = 'Publish to npm';
return run(cmd, msg);
}
function _gitBranchName() {
var cmd = 'git rev-parse --abbrev-ref HEAD';
return run(cmd, false);
}
main();