Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inconsistency with dangling commas #317

Merged
merged 1 commit into from Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.json
Expand Up @@ -17,6 +17,7 @@
"no-var": "error",
"prefer-const": "error",
"quotes": ["error", "single"],
"comma-dangle": ["error", "always-multiline"],
"semi": "error",
"space-before-blocks": "error",
"space-before-function-paren": ["error", {
Expand Down
14 changes: 7 additions & 7 deletions bin/concurrently.spec.ts
Expand Up @@ -8,7 +8,7 @@ const isWindows = process.platform === 'win32';
const createKillMessage = (prefix: string) => new RegExp(
_.escapeRegExp(prefix) +
' exited with code ' +
(isWindows ? 1 : '(SIGTERM|143)')
(isWindows ? 1 : '(SIGTERM|143)'),
);

/**
Expand All @@ -22,31 +22,31 @@ const run = (args: string) => {
env: Object.assign({}, process.env, {
// When upgrading from jest 23 -> 24, colors started printing in the test output.
// They are forcibly disabled here
FORCE_COLOR: 0
FORCE_COLOR: 0,
}),
});

const stdout = readline.createInterface({
input: child.stdout,
output: null
output: null,
});

const stderr = readline.createInterface({
input: child.stderr,
output: null
output: null,
});

const close = Rx.fromEvent<[number | null, NodeJS.Signals | null]>(child, 'close');
const log = Rx.merge(
Rx.fromEvent<Buffer>(stdout, 'line'),
Rx.fromEvent<Buffer>(stderr, 'line')
Rx.fromEvent<Buffer>(stderr, 'line'),
).pipe(map(data => data.toString()));

return {
close,
log,
stdin: child.stdin,
pid: child.pid
pid: child.pid,
};
};

Expand All @@ -61,7 +61,7 @@ it('has version command', done => {
Rx.combineLatest(
run('--version').close,
run('-V').close,
run('-v').close
run('-v').close,
).subscribe(events => {
expect(events[0][0]).toBe(0);
expect(events[1][0]).toBe(0);
Expand Down
44 changes: 22 additions & 22 deletions bin/concurrently.ts
Expand Up @@ -20,14 +20,14 @@ const args = yargs
describe:
'How many processes should run at once.\n' +
'New processes only spawn after all restart tries of a process.',
type: 'number'
type: 'number',
},
'names': {
alias: 'n',
describe:
'List of custom names to be used in prefix template.\n' +
'Example names: "main,browser,server"',
type: 'string'
type: 'string',
},
'name-separator': {
describe:
Expand All @@ -42,48 +42,48 @@ const args = yargs
'of the "first" child to terminate, the "last child", or succeed ' +
'only if "all" child processes succeed.',
choices: ['first', 'last', 'all'] as const,
default: defaults.success
default: defaults.success,
},
'raw': {
alias: 'r',
describe:
'Output only raw output of processes, disables prettifying ' +
'and concurrently coloring.',
type: 'boolean'
type: 'boolean',
},
// This one is provided for free. Chalk reads this itself and removes colours.
// https://www.npmjs.com/package/chalk#chalksupportscolor
'no-color': {
describe: 'Disables colors from logging',
type: 'boolean'
type: 'boolean',
},
'hide': {
describe:
'Comma-separated list of processes to hide the output.\n' +
'The processes can be identified by their name or index.',
default: defaults.hide,
type: 'string'
type: 'string',
},
'group': {
alias: 'g',
describe: 'Order the output as if the commands were run sequentially.',
type: 'boolean'
type: 'boolean',
},
'timings': {
describe: 'Show timing information for all processes',
type: 'boolean',
default: defaults.timings
default: defaults.timings,
},

// Kill others
'kill-others': {
alias: 'k',
describe: 'kill other processes if one exits or dies',
type: 'boolean'
type: 'boolean',
},
'kill-others-on-fail': {
describe: 'kill other processes if one exits with non zero status code',
type: 'boolean'
type: 'boolean',
},

// Prefix
Expand All @@ -94,7 +94,7 @@ const args = yargs
'Possible values: index, pid, time, command, name, none, or a template. ' +
'Example template: "{time}-{pid}"',
defaultDescription: 'index or name (when --names is set)',
type: 'string'
type: 'string',
},
'prefix-colors': {
alias: 'c',
Expand All @@ -107,21 +107,21 @@ const args = yargs
'- Available background colors: bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite\n' +
'See https://www.npmjs.com/package/chalk for more information.',
default: defaults.prefixColors,
type: 'string'
type: 'string',
},
'prefix-length': {
alias: 'l',
describe:
'Limit how many characters of the command is displayed in prefix. ' +
'The option can be used to shorten the prefix when it is set to "command"',
default: defaults.prefixLength,
type: 'number'
type: 'number',
},
'timestamp-format': {
alias: 't',
describe: 'Specify the timestamp in moment/date-fns format.',
default: defaults.timestampFormat,
type: 'string'
type: 'string',
},

// Restarting
Expand All @@ -130,12 +130,12 @@ const args = yargs
'How many times a process that died should restart.\n' +
'Negative numbers will make the process restart forever.',
default: defaults.restartTries,
type: 'number'
type: 'number',
},
'restart-after': {
describe: 'Delay time to respawn the process, in milliseconds.',
default: defaults.restartDelay,
type: 'number'
type: 'number',
},

// Input
Expand All @@ -144,15 +144,15 @@ const args = yargs
describe:
'Whether input should be forwarded to the child processes. ' +
'See examples for more information.',
type: 'boolean'
type: 'boolean',
},
'default-input-target': {
default: defaults.defaultInputTarget,
describe:
'Identifier for child process to which input on stdin ' +
'should be sent if not specified at start of input.\n' +
'Can be either the index or the name of the process.'
}
'Can be either the index or the name of the process.',
},
})
.group(['m', 'n', 'name-separator', 'raw', 's', 'no-color', 'hide', 'group', 'timings'], 'General')
.group(['p', 'c', 'l', 't'], 'Prefix styling')
Expand All @@ -166,7 +166,7 @@ const names = (args.names || '').split(args['name-separator']);

concurrently(args._.map((command, index) => ({
command: String(command),
name: names[index]
name: names[index],
})), {
handleInput: args['handle-input'],
defaultInputTarget: args['default-input-target'],
Expand All @@ -184,8 +184,8 @@ concurrently(args._.map((command, index) => ({
restartTries: args['restart-tries'],
successCondition: args.success,
timestampFormat: args['timestamp-format'],
timings: args.timings
timings: args.timings,
}).result.then(
() => process.exit(0),
() => process.exit(1)
() => process.exit(1),
);
14 changes: 7 additions & 7 deletions bin/epilogue.ts
Expand Up @@ -3,11 +3,11 @@
const examples = [
{
description: 'Output nothing more than stdout+stderr of child processes',
example: '$ $0 --raw "npm run watch-less" "npm run watch-js"'
example: '$ $0 --raw "npm run watch-less" "npm run watch-js"',
},
{
description: 'Normal output but without colors e.g. when logging to file',
example: '$ $0 --no-color "grunt watch" "http-server" > log'
example: '$ $0 --no-color "grunt watch" "http-server" > log',
},
{
description: 'Custom prefix',
Expand All @@ -25,21 +25,21 @@ const examples = [
description: 'Send input to default',
example: [
'$ $0 --handle-input "nodemon" "npm run watch-js"',
'rs # Sends rs command to nodemon process'
'rs # Sends rs command to nodemon process',
].join('\n'),
},
{
description: 'Send input to specific child identified by index',
example: [
'$ $0 --handle-input "npm run watch-js" nodemon',
'1:rs'
'1:rs',
].join('\n'),
},
{
description: 'Send input to specific child identified by name',
example: [
'$ $0 --handle-input -n js,srv "npm run watch-js" nodemon',
'srv:rs'
'srv:rs',
].join('\n'),
},
{
Expand All @@ -52,8 +52,8 @@ const examples = [
},
{
description: 'Exclude patterns so that between "lint:js" and "lint:fix:js", only "lint:js" is ran',
example: '$ $0 "npm:*(!fix)"'
}
example: '$ $0 "npm:*(!fix)"',
},
];

export const epilogue = `
Expand Down
4 changes: 2 additions & 2 deletions src/command-parser/expand-npm-shortcut.spec.ts
Expand Up @@ -19,7 +19,7 @@ for (const npmCmd of ['npm', 'yarn', 'pnpm']) {
expect(parser.parse(commandInfo)).toEqual({
...commandInfo,
name: 'echo',
command: `${npmCmd} run foo -- bar`
command: `${npmCmd} run foo -- bar`,
});
});

Expand All @@ -28,7 +28,7 @@ for (const npmCmd of ['npm', 'yarn', 'pnpm']) {
expect(parser.parse(commandInfo)).toEqual({
...commandInfo,
name: 'foo',
command: `${npmCmd} run foo -- bar`
command: `${npmCmd} run foo -- bar`,
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/command-parser/expand-npm-shortcut.ts
Expand Up @@ -13,7 +13,7 @@ export class ExpandNpmShortcut implements CommandParser {

return Object.assign({}, commandInfo, {
name: commandInfo.name || cmdName,
command: `${npmCmd} run ${cmdName}${args}`
command: `${npmCmd} run ${cmdName}${args}`,
});
}
};
6 changes: 3 additions & 3 deletions src/command-parser/expand-npm-wildcard.spec.ts
Expand Up @@ -74,7 +74,7 @@ for (const npmCmd of ['npm', 'yarn', 'pnpm']) {
scripts: {
'foo-bar-baz': '',
'foo--baz': '',
}
},
});

expect(parser.parse(createCommandInfo(`${npmCmd} run foo-*-baz qux`))).toEqual([
Expand All @@ -88,7 +88,7 @@ for (const npmCmd of ['npm', 'yarn', 'pnpm']) {
scripts: {
'watch-js': '',
'watch-css': '',
}
},
});

expect(parser.parse({
Expand All @@ -107,7 +107,7 @@ for (const npmCmd of ['npm', 'yarn', 'pnpm']) {
'lint:ts': '',
'lint:fix:js': '',
'lint:fix:ts': '',
}
},
});

expect(parser.parse(createCommandInfo(`${npmCmd} run lint:*(!fix)`))).toEqual([
Expand Down
2 changes: 1 addition & 1 deletion src/command.ts
Expand Up @@ -161,7 +161,7 @@ export class Command implements CommandInfo {
startDate,
endDate,
durationSeconds: durationSeconds + (durationNanoSeconds / 1e9),
}
},
});
});
child.stdout && pipeTo(Rx.fromEvent<Buffer>(child.stdout, 'data'), this.stdout);
Expand Down
2 changes: 1 addition & 1 deletion src/completion-listener.spec.ts
Expand Up @@ -12,7 +12,7 @@ beforeEach(() => {
const createController = (successCondition?: SuccessCondition) =>
new CompletionListener({
successCondition,
scheduler
scheduler,
});

describe('with default success condition set', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/completion-listener.ts
Expand Up @@ -64,7 +64,7 @@ export class CompletionListener {
switchMap(exitInfos =>
this.isSuccess(exitInfos.map(({ exitCode }) => exitCode))
? Rx.of(exitInfos, this.scheduler)
: Rx.throwError(exitInfos, this.scheduler)
: Rx.throwError(exitInfos, this.scheduler),
),
take(1),
)
Expand Down