From 39fddeffb1ad2c093235427453ea001b67ec201a Mon Sep 17 00:00:00 2001 From: Pascal Jufer Date: Tue, 26 Apr 2022 00:23:05 +0200 Subject: [PATCH] Fix inconsistency with dangling commas (#317) --- .eslintrc.json | 1 + bin/concurrently.spec.ts | 14 +++--- bin/concurrently.ts | 44 +++++++++---------- bin/epilogue.ts | 14 +++--- .../expand-npm-shortcut.spec.ts | 4 +- src/command-parser/expand-npm-shortcut.ts | 2 +- .../expand-npm-wildcard.spec.ts | 6 +-- src/command.ts | 2 +- src/completion-listener.spec.ts | 2 +- src/completion-listener.ts | 2 +- src/concurrently.spec.ts | 22 +++++----- src/concurrently.ts | 8 ++-- src/flow-control/input-handler.spec.ts | 2 +- src/flow-control/kill-on-signal.ts | 4 +- src/flow-control/kill-others.spec.ts | 4 +- src/flow-control/kill-others.ts | 2 +- src/flow-control/log-error.spec.ts | 4 +- src/flow-control/log-error.ts | 2 +- src/flow-control/log-exit.spec.ts | 4 +- src/flow-control/log-timings.spec.ts | 12 ++--- src/flow-control/restart-process.spec.ts | 12 ++--- src/flow-control/restart-process.ts | 8 ++-- src/get-spawn-opts.spec.ts | 2 +- src/get-spawn-opts.ts | 2 +- src/index.ts | 4 +- src/logger.spec.ts | 4 +- 26 files changed, 94 insertions(+), 93 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 8d217911..d1464b3e 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -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", { diff --git a/bin/concurrently.spec.ts b/bin/concurrently.spec.ts index e0c1519c..b8ac8537 100644 --- a/bin/concurrently.spec.ts +++ b/bin/concurrently.spec.ts @@ -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)'), ); /** @@ -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(stdout, 'line'), - Rx.fromEvent(stderr, 'line') + Rx.fromEvent(stderr, 'line'), ).pipe(map(data => data.toString())); return { close, log, stdin: child.stdin, - pid: child.pid + pid: child.pid, }; }; @@ -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); diff --git a/bin/concurrently.ts b/bin/concurrently.ts index f06a6a6b..f7dd870c 100755 --- a/bin/concurrently.ts +++ b/bin/concurrently.ts @@ -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: @@ -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 @@ -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', @@ -107,7 +107,7 @@ 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', @@ -115,13 +115,13 @@ const args = yargs '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 @@ -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 @@ -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') @@ -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'], @@ -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), ); diff --git a/bin/epilogue.ts b/bin/epilogue.ts index 59a7ee82..1fce3805 100644 --- a/bin/epilogue.ts +++ b/bin/epilogue.ts @@ -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', @@ -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'), }, { @@ -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 = ` diff --git a/src/command-parser/expand-npm-shortcut.spec.ts b/src/command-parser/expand-npm-shortcut.spec.ts index 97028fdc..64fac94c 100644 --- a/src/command-parser/expand-npm-shortcut.spec.ts +++ b/src/command-parser/expand-npm-shortcut.spec.ts @@ -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`, }); }); @@ -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`, }); }); }); diff --git a/src/command-parser/expand-npm-shortcut.ts b/src/command-parser/expand-npm-shortcut.ts index 9ce2ef29..ef07ad62 100644 --- a/src/command-parser/expand-npm-shortcut.ts +++ b/src/command-parser/expand-npm-shortcut.ts @@ -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}`, }); } }; diff --git a/src/command-parser/expand-npm-wildcard.spec.ts b/src/command-parser/expand-npm-wildcard.spec.ts index cd16ae71..ad160795 100644 --- a/src/command-parser/expand-npm-wildcard.spec.ts +++ b/src/command-parser/expand-npm-wildcard.spec.ts @@ -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([ @@ -88,7 +88,7 @@ for (const npmCmd of ['npm', 'yarn', 'pnpm']) { scripts: { 'watch-js': '', 'watch-css': '', - } + }, }); expect(parser.parse({ @@ -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([ diff --git a/src/command.ts b/src/command.ts index 9c76e66b..2ee253db 100644 --- a/src/command.ts +++ b/src/command.ts @@ -161,7 +161,7 @@ export class Command implements CommandInfo { startDate, endDate, durationSeconds: durationSeconds + (durationNanoSeconds / 1e9), - } + }, }); }); child.stdout && pipeTo(Rx.fromEvent(child.stdout, 'data'), this.stdout); diff --git a/src/completion-listener.spec.ts b/src/completion-listener.spec.ts index f1c4e3aa..bba17f5a 100644 --- a/src/completion-listener.spec.ts +++ b/src/completion-listener.spec.ts @@ -12,7 +12,7 @@ beforeEach(() => { const createController = (successCondition?: SuccessCondition) => new CompletionListener({ successCondition, - scheduler + scheduler, }); describe('with default success condition set', () => { diff --git a/src/completion-listener.ts b/src/completion-listener.ts index 03794ffa..732d0fdd 100644 --- a/src/completion-listener.ts +++ b/src/completion-listener.ts @@ -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), ) diff --git a/src/concurrently.spec.ts b/src/concurrently.spec.ts index ef0b6dfa..ec13d990 100644 --- a/src/concurrently.spec.ts +++ b/src/concurrently.spec.ts @@ -10,7 +10,7 @@ let controllers: jest.Mocked[]; let processes: ChildProcess[]; const create = (commands: ConcurrentlyCommandInput[], options: Partial = {}) => concurrently( commands, - Object.assign(options, { controllers, spawn, kill }) + Object.assign(options, { controllers, spawn, kill }), ); beforeEach(() => { @@ -80,7 +80,7 @@ it('runs controllers with the commands', () => { it('runs commands with a name or prefix color', () => { create([ { command: 'echo', prefixColor: 'red', name: 'foo' }, - 'kill' + 'kill', ]); controllers.forEach(controller => { @@ -93,7 +93,7 @@ it('runs commands with a name or prefix color', () => { it('runs commands with a list of colors', () => { create(['echo', 'kill'], { - prefixColors: ['red'] + prefixColors: ['red'], }); controllers.forEach(controller => { @@ -111,7 +111,7 @@ it('passes commands wrapped from a controller to the next one', () => { create(['echo']); expect(controllers[0].handle).toHaveBeenCalledWith([ - expect.objectContaining({ command: 'echo', index: 0 }) + expect.objectContaining({ command: 'echo', index: 0 }), ]); expect(controllers[1].handle).toHaveBeenCalledWith([fakeCommand]); @@ -123,18 +123,18 @@ it('merges extra env vars into each command', () => { create([ { command: 'echo', env: { foo: 'bar' } }, { command: 'echo', env: { foo: 'baz' } }, - 'kill' + 'kill', ]); expect(spawn).toHaveBeenCalledTimes(3); expect(spawn).toHaveBeenCalledWith('echo', expect.objectContaining({ - env: expect.objectContaining({ foo: 'bar' }) + env: expect.objectContaining({ foo: 'bar' }), })); expect(spawn).toHaveBeenCalledWith('echo', expect.objectContaining({ - env: expect.objectContaining({ foo: 'baz' }) + env: expect.objectContaining({ foo: 'baz' }), })); expect(spawn).toHaveBeenCalledWith('kill', expect.objectContaining({ - env: expect.not.objectContaining({ foo: expect.anything() }) + env: expect.not.objectContaining({ foo: expect.anything() }), })); }); @@ -143,11 +143,11 @@ it('uses cwd from options for each command', () => { [ { command: 'echo', env: { foo: 'bar' } }, { command: 'echo', env: { foo: 'baz' } }, - 'kill' + 'kill', ], { cwd: 'foobar', - } + }, ); expect(spawn).toHaveBeenCalledTimes(3); @@ -173,7 +173,7 @@ it('uses overridden cwd option for each command if specified', () => { ], { cwd: 'foobar', - } + }, ); expect(spawn).toHaveBeenCalledTimes(2); diff --git a/src/concurrently.ts b/src/concurrently.ts index 88419dbe..29c97412 100644 --- a/src/concurrently.ts +++ b/src/concurrently.ts @@ -116,7 +116,7 @@ export function concurrently( const commandParsers: CommandParser[] = [ new StripQuotes(), new ExpandNpmShortcut(), - new ExpandNpmWildcard() + new ExpandNpmWildcard(), ]; let lastColor = ''; @@ -142,10 +142,10 @@ export function concurrently( const { commands, onFinish } = controller.handle(prevCommands); return { commands, - onFinishCallbacks: _.concat(onFinishCallbacks, onFinish ? [onFinish] : []) + onFinishCallbacks: _.concat(onFinishCallbacks, onFinish ? [onFinish] : []), }; }, - { commands, onFinishCallbacks: [] } + { commands, onFinishCallbacks: [] }, ); commands = handleResult.commands; @@ -200,7 +200,7 @@ function mapToCommandInfo(command: ConcurrentlyCommandInput): CommandInfo { function parseCommand(command: CommandInfo, parsers: CommandParser[]) { return parsers.reduce( (commands, parser) => _.flatMap(commands, command => parser.parse(command)), - _.castArray(command) + _.castArray(command), ); } diff --git a/src/flow-control/input-handler.spec.ts b/src/flow-control/input-handler.spec.ts index c41799ed..9d6186cd 100644 --- a/src/flow-control/input-handler.spec.ts +++ b/src/flow-control/input-handler.spec.ts @@ -20,7 +20,7 @@ beforeEach(() => { controller = new InputHandler({ defaultInputTarget: 0, inputStream, - logger + logger, }); }); diff --git a/src/flow-control/kill-on-signal.ts b/src/flow-control/kill-on-signal.ts index 5471fa4a..9de9d635 100644 --- a/src/flow-control/kill-on-signal.ts +++ b/src/flow-control/kill-on-signal.ts @@ -32,9 +32,9 @@ export class KillOnSignal implements FlowController { return new Proxy(command, { get(target, prop: keyof Command) { return prop === 'close' ? closeStream : target[prop]; - } + }, }); - }) + }), }; } }; diff --git a/src/flow-control/kill-others.spec.ts b/src/flow-control/kill-others.spec.ts index a2a42093..78df46ad 100644 --- a/src/flow-control/kill-others.spec.ts +++ b/src/flow-control/kill-others.spec.ts @@ -8,7 +8,7 @@ let logger: Logger; beforeEach(() => { commands = [ new FakeCommand(), - new FakeCommand() + new FakeCommand(), ]; logger = createMockInstance(Logger); @@ -16,7 +16,7 @@ beforeEach(() => { const createWithConditions = (conditions: ProcessCloseCondition[]) => new KillOthers({ logger, - conditions + conditions, }); it('returns same commands', () => { diff --git a/src/flow-control/kill-others.ts b/src/flow-control/kill-others.ts index cbe6d025..6a64fe94 100644 --- a/src/flow-control/kill-others.ts +++ b/src/flow-control/kill-others.ts @@ -34,7 +34,7 @@ export class KillOthers implements FlowController { const closeStates = commands.map(command => command.close.pipe( map(({ exitCode }) => exitCode === 0 ? 'success' as const : 'failure' as const), - filter(state => conditions.includes(state)) + filter(state => conditions.includes(state)), )); closeStates.forEach(closeState => closeState.subscribe(() => { diff --git a/src/flow-control/log-error.spec.ts b/src/flow-control/log-error.spec.ts index 42a2e1fc..cdab2a26 100644 --- a/src/flow-control/log-error.spec.ts +++ b/src/flow-control/log-error.spec.ts @@ -30,13 +30,13 @@ it('logs the error event of each command', () => { expect(logger.logCommandEvent).toHaveBeenCalledTimes(4); expect(logger.logCommandEvent).toHaveBeenCalledWith( `Error occurred when executing command: ${commands[0].command}`, - commands[0] + commands[0], ); expect(logger.logCommandEvent).toHaveBeenCalledWith('error from command 0', commands[0]); expect(logger.logCommandEvent).toHaveBeenCalledWith( `Error occurred when executing command: ${commands[1].command}`, - commands[1] + commands[1], ); expect(logger.logCommandEvent).toHaveBeenCalledWith(error.stack, commands[1]); }); diff --git a/src/flow-control/log-error.ts b/src/flow-control/log-error.ts index b31772f0..6d80899a 100644 --- a/src/flow-control/log-error.ts +++ b/src/flow-control/log-error.ts @@ -16,7 +16,7 @@ export class LogError implements FlowController { commands.forEach(command => command.error.subscribe(event => { this.logger.logCommandEvent( `Error occurred when executing command: ${command.command}`, - command + command, ); const errorText = String(event instanceof Error ? (event.stack || event) : event); diff --git a/src/flow-control/log-exit.spec.ts b/src/flow-control/log-exit.spec.ts index c8681100..33615b76 100644 --- a/src/flow-control/log-exit.spec.ts +++ b/src/flow-control/log-exit.spec.ts @@ -29,10 +29,10 @@ it('logs the close event of each command', () => { expect(logger.logCommandEvent).toHaveBeenCalledTimes(2); expect(logger.logCommandEvent).toHaveBeenCalledWith( `${commands[0].command} exited with code 0`, - commands[0] + commands[0], ); expect(logger.logCommandEvent).toHaveBeenCalledWith( `${commands[1].command} exited with code SIGTERM`, - commands[1] + commands[1], ); }); diff --git a/src/flow-control/log-timings.spec.ts b/src/flow-control/log-timings.spec.ts index 74305e81..edecabfe 100644 --- a/src/flow-control/log-timings.spec.ts +++ b/src/flow-control/log-timings.spec.ts @@ -79,19 +79,19 @@ it('logs the timings at the start and end (ie complete or error) event of each c expect(logger.logCommandEvent).toHaveBeenCalledTimes(4); expect(logger.logCommandEvent).toHaveBeenCalledWith( `${commands[0].command} started at ${formatDate(startDate0, timestampFormat)}`, - commands[0] + commands[0], ); expect(logger.logCommandEvent).toHaveBeenCalledWith( `${commands[1].command} started at ${formatDate(startDate1, timestampFormat)}`, - commands[1] + commands[1], ); expect(logger.logCommandEvent).toHaveBeenCalledWith( `${commands[1].command} stopped at ${formatDate(endDate1, timestampFormat)} after ${command1DurationTextMs}`, - commands[1] + commands[1], ); expect(logger.logCommandEvent).toHaveBeenCalledWith( `${commands[0].command} stopped at ${formatDate(endDate0, timestampFormat)} after ${command0DurationTextMs}`, - commands[0] + commands[0], ); }); @@ -117,13 +117,13 @@ it('logs the sorted timings summary when all processes close successfully', () = // un-sorted ie by finish order expect(controller.printExitInfoTimingTable).toHaveBeenCalledWith([ command0ExitInfo, - command1ExitInfo + command1ExitInfo, ]); // sorted by duration expect(logger.logTable).toHaveBeenCalledWith([ LogTimings.mapCloseEventToTimingInfo(command1ExitInfo), - LogTimings.mapCloseEventToTimingInfo(command0ExitInfo) + LogTimings.mapCloseEventToTimingInfo(command0ExitInfo), ]); }); diff --git a/src/flow-control/restart-process.spec.ts b/src/flow-control/restart-process.spec.ts index 0026eac8..a1950bb2 100644 --- a/src/flow-control/restart-process.spec.ts +++ b/src/flow-control/restart-process.spec.ts @@ -11,7 +11,7 @@ let scheduler: TestScheduler; beforeEach(() => { commands = [ new FakeCommand(), - new FakeCommand() + new FakeCommand(), ]; logger = createMockInstance(Logger); @@ -20,7 +20,7 @@ beforeEach(() => { logger, scheduler, delay: 100, - tries: 2 + tries: 2, }); }); @@ -47,7 +47,7 @@ it('restarts processes that fail after delay has passed', () => { expect(logger.logCommandEvent).toHaveBeenCalledTimes(1); expect(logger.logCommandEvent).toHaveBeenCalledWith( `${commands[0].command} restarted`, - commands[0] + commands[0], ); expect(commands[0].start).toHaveBeenCalledTimes(1); expect(commands[1].start).not.toHaveBeenCalled(); @@ -66,7 +66,7 @@ it('restarts processes up to tries', () => { expect(logger.logCommandEvent).toHaveBeenCalledTimes(2); expect(logger.logCommandEvent).toHaveBeenCalledWith( `${commands[0].command} restarted`, - commands[0] + commands[0], ); expect(commands[0].start).toHaveBeenCalledTimes(2); }); @@ -76,7 +76,7 @@ it('restart processes forever, if tries is negative', () => { logger, scheduler, delay: 100, - tries: -1 + tries: -1, }); expect(controller.tries).toBe(Infinity); }); @@ -93,7 +93,7 @@ it('restarts processes until they succeed', () => { expect(logger.logCommandEvent).toHaveBeenCalledTimes(1); expect(logger.logCommandEvent).toHaveBeenCalledWith( `${commands[0].command} restarted`, - commands[0] + commands[0], ); expect(commands[0].start).toHaveBeenCalledTimes(1); }); diff --git a/src/flow-control/restart-process.ts b/src/flow-control/restart-process.ts index 63ad2b11..b1b15c9e 100644 --- a/src/flow-control/restart-process.ts +++ b/src/flow-control/restart-process.ts @@ -34,7 +34,7 @@ export class RestartProcess implements FlowController { commands.map(command => command.close.pipe( take(this.tries), - takeWhile(({ exitCode }) => exitCode !== 0) + takeWhile(({ exitCode }) => exitCode !== 0), )).map((failure, index) => Rx.merge( // Delay the emission (so that the restarts happen on time), // explicitly telling the subscriber that a restart is needed @@ -42,7 +42,7 @@ export class RestartProcess implements FlowController { // Skip the first N emissions (as these would be duplicates of the above), // meaning it will be empty because of success, or failed all N times, // and no more restarts should be attempted. - failure.pipe(skip(this.tries), mapTo(false), defaultIfEmpty(false)) + failure.pipe(skip(this.tries), mapTo(false), defaultIfEmpty(false)), ).subscribe(restart => { const command = commands[index]; if (restart) { @@ -61,9 +61,9 @@ export class RestartProcess implements FlowController { return new Proxy(command, { get(target, prop: keyof Command) { return prop === 'close' ? closeStream : target[prop]; - } + }, }); - }) + }), }; } }; diff --git a/src/get-spawn-opts.spec.ts b/src/get-spawn-opts.spec.ts index 040aa5ad..596cc2a0 100644 --- a/src/get-spawn-opts.spec.ts +++ b/src/get-spawn-opts.spec.ts @@ -19,7 +19,7 @@ it('merges FORCE_COLOR into env vars if color supported', () => { expect(getSpawnOpts({ process, colorSupport: false }).env).toEqual(process.env); expect(getSpawnOpts({ process, colorSupport: { level: 1 } }).env).toEqual({ FORCE_COLOR: 1, - foo: 'bar' + foo: 'bar', }); }); diff --git a/src/get-spawn-opts.ts b/src/get-spawn-opts.ts index 7957ddc9..8f7419d0 100644 --- a/src/get-spawn-opts.ts +++ b/src/get-spawn-opts.ts @@ -43,5 +43,5 @@ export const getSpawnOpts = ({ }, raw && { stdio: 'inherit' as const }, /^win/.test(process.platform) && { detached: false }, - { env: Object.assign(colorSupport ? { FORCE_COLOR: colorSupport.level } : {}, process.env, env) } + { env: Object.assign(colorSupport ? { FORCE_COLOR: colorSupport.level } : {}, process.env, env) }, ); diff --git a/src/index.ts b/src/index.ts index 0b4b9f5e..b3704245 100644 --- a/src/index.ts +++ b/src/index.ts @@ -114,12 +114,12 @@ export default (commands: ConcurrentlyCommandInput[], options: Partial { it('logs prefix using prefixColor from command', () => { const logger = createLogger({}); const cmd = new FakeCommand('', undefined, 1, { - prefixColor: 'blue' + prefixColor: 'blue', }); logger.logCommandText('foo', cmd); @@ -178,7 +178,7 @@ describe('#logCommandText()', () => { it('logs prefix in gray dim if prefixColor from command does not exist', () => { const logger = createLogger({}); const cmd = new FakeCommand('', undefined, 1, { - prefixColor: 'blue.fake' + prefixColor: 'blue.fake', }); logger.logCommandText('foo', cmd);