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

Replace date-fns by date-and-time-formatter #443

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,10 @@ concurrently [options] <command ...>

General
-m, --max-processes How many processes should run at once.
Exact number or a percent of CPUs available (for example "50%").
New processes only spawn after all restart tries
of a process. [string]
of a process.
Exact number or a percent of CPUs available (for
example "50%") [string]
-n, --names List of custom names to be used in prefix
template.
Example names: "main,browser,server" [string]
Expand Down Expand Up @@ -202,7 +203,7 @@ Prefix styling
in prefix. The option can be used to shorten the
prefix when it is set to "command"
[number] [default: 10]
-t, --timestamp-format Specify the timestamp in moment/date-fns format.
-t, --timestamp-format Specify the timestamp in Unicode LDML format.
[string] [default: "yyyy-MM-dd HH:mm:ss.SSS"]

Input handling
Expand All @@ -219,8 +220,9 @@ Killing other processes
-k, --kill-others Kill other processes if one exits or dies.[boolean]
--kill-others-on-fail Kill other processes if one exits with non zero
status code. [boolean]
--kill-signal Signal to send to other processes if one exits or dies.
(SIGTERM/SIGKILL, defaults to SIGTERM) [string]
--kill-signal, --ks Signal to send to other processes if one exits or
dies. (SIGTERM/SIGKILL, defaults to SIGTERM)
[string]

Restarting
--restart-tries How many times a process that died should restart.
Expand Down Expand Up @@ -346,7 +348,7 @@ For more details, visit https://github.com/open-cli-tools/concurrently
Anything else means all processes should exit successfully.
- `restartTries`: how many attempts to restart a process that dies will be made. Default: `0`.
- `restartDelay`: how many milliseconds to wait between process restarts. Default: `0`.
- `timestampFormat`: a [date-fns format](https://date-fns.org/v2.0.1/docs/format)
- `timestampFormat`: a [Unicode LDML format](https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `timestampFormat`: a [Unicode LDML format](https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table)
- `timestampFormat`: a [Unicode LDML date format](https://unicode.org/reports/tr35/tr35-dates.html#Date_Format_Patterns)

to use when prefixing with `time`. Default: `yyyy-MM-dd HH:mm:ss.ZZZ`
- `additionalArguments`: list of additional arguments passed that will get replaced in each command. If not defined, no argument replacing will happen.

Expand Down
2 changes: 1 addition & 1 deletion bin/concurrently.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ const args = yargs(argsBeforeSep)
},
'timestamp-format': {
alias: 't',
describe: 'Specify the timestamp in moment/date-fns format.',
describe: 'Specify the timestamp in Unicode LDML format.',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this is technically correct, I wonder how many people won't know how to find usage examples for LDML.

For instance, for me, Google returns one result for "unicode ldml" in the first page that is more "straight to the point" IMO:
https://stackoverflow.com/q/39904392/2083599

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Should we explicitly link https://unicode.org/reports/tr35/tr35-dates.html#Date_Format_Patterns in this description?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably, but i'm worried it might not be formatted well by yargs.

Something like #445 (or better) is looking promising now...

default: defaults.timestampFormat,
type: 'string',
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"license": "MIT",
"dependencies": {
"chalk": "^4.1.2",
"date-fns": "^2.30.0",
"date-and-time-formatter": "^1.0.0",
"lodash": "^4.17.21",
"rxjs": "^7.8.1",
"shell-quote": "^1.8.1",
Expand Down
25 changes: 6 additions & 19 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const success = 'all' as SuccessCondition;

/**
* Date format used when logging date/time.
* @see https://date-fns.org/v2.0.1/docs/format
* @see https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @see https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
* @see https://unicode.org/reports/tr35/tr35-dates.html#Date_Format_Patterns

*/
export const timestampFormat = 'yyyy-MM-dd HH:mm:ss.SSS';

Expand Down
10 changes: 5 additions & 5 deletions src/flow-control/log-timings.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import formatDate from 'date-fns/format';
import { formatDateTime } from 'date-and-time-formatter';
import { createMockInstance } from 'jest-create-mock-instance';

import { CloseEvent } from '../command';
Expand Down Expand Up @@ -79,22 +79,22 @@ 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].command} started at ${formatDateTime(startDate0, timestampFormat)}`,
commands[0],
);
expect(logger.logCommandEvent).toHaveBeenCalledWith(
`${commands[1].command} started at ${formatDate(startDate1, timestampFormat)}`,
`${commands[1].command} started at ${formatDateTime(startDate1, timestampFormat)}`,
commands[1],
);
expect(logger.logCommandEvent).toHaveBeenCalledWith(
`${commands[1].command} stopped at ${formatDate(
`${commands[1].command} stopped at ${formatDateTime(
endDate1,
timestampFormat,
)} after ${command1DurationTextMs}`,
commands[1],
);
expect(logger.logCommandEvent).toHaveBeenCalledWith(
`${commands[0].command} stopped at ${formatDate(
`${commands[0].command} stopped at ${formatDateTime(
endDate0,
timestampFormat,
)} after ${command0DurationTextMs}`,
Expand Down
6 changes: 3 additions & 3 deletions src/flow-control/log-timings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as assert from 'assert';
import formatDate from 'date-fns/format';
import { formatDateTime } from 'date-and-time-formatter';
import _ from 'lodash';
import * as Rx from 'rxjs';
import { bufferCount, combineLatestWith, take } from 'rxjs/operators';
Expand Down Expand Up @@ -77,14 +77,14 @@ export class LogTimings implements FlowController {
commands.forEach((command) => {
command.timer.subscribe(({ startDate, endDate }) => {
if (!endDate) {
const formattedStartDate = formatDate(startDate, this.timestampFormat);
const formattedStartDate = formatDateTime(startDate, this.timestampFormat);
logger.logCommandEvent(
`${command.command} started at ${formattedStartDate}`,
command,
);
} else {
const durationMs = endDate.getTime() - startDate.getTime();
const formattedEndDate = formatDate(endDate, this.timestampFormat);
const formattedEndDate = formatDateTime(endDate, this.timestampFormat);
logger.logCommandEvent(
`${
command.command
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export type ConcurrentlyOptions = BaseConcurrentlyOptions & {

/**
* Date format used when logging date/time.
* @see https://date-fns.org/v2.0.1/docs/format
* @see https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @see https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
* @see https://unicode.org/reports/tr35/tr35-dates.html#Date_Format_Patterns

*/
timestampFormat?: string;

Expand Down
6 changes: 3 additions & 3 deletions src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import chalk from 'chalk';
import formatDate from 'date-fns/format';
import { formatDateTime } from 'date-and-time-formatter';
import _ from 'lodash';
import * as Rx from 'rxjs';

Expand Down Expand Up @@ -56,7 +56,7 @@ export class Logger {

/**
* Date format used when logging date/time.
* @see https://date-fns.org/v2.0.1/docs/format
* @see https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
*/
timestampFormat?: string;
}) {
Expand Down Expand Up @@ -93,7 +93,7 @@ export class Logger {
index: String(command.index),
name: command.name,
command: this.shortenText(command.command),
time: formatDate(Date.now(), this.timestampFormat),
time: formatDateTime(new Date(), this.timestampFormat),
};
}

Expand Down