Skip to content

Commit ff8cefb

Browse files
authored
Use minimalist logging prefix with concurrently (#535)
1 parent a1f9ae5 commit ff8cefb

File tree

7 files changed

+41
-21
lines changed

7 files changed

+41
-21
lines changed

.changeset/stale-numbers-carry.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'skuba': patch
3+
---
4+
5+
**build-package, lint:** Use minimalist logging prefix

docs/cli/build.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ This is useful for building isomorphic npm packages, and serves as a replacement
6161
```shell
6262
skuba build-package
6363

64-
# [commonjs] TSFILE: ...
65-
# [commonjs] tsc exited with code 0
66-
# [es2015 ] TSFILE: ...
67-
# [es2015 ] tsc exited with code 0
68-
# [types ] TSFILE: ...
69-
# [types ] tsc exited with code 0
64+
# commonjs | TSFILE: ...
65+
# commonjs | tsc exited with code 0
66+
# es2015 | TSFILE: ...
67+
# es2015 | tsc exited with code 0
68+
# types | TSFILE: ...
69+
# types | tsc exited with code 0
7070
```
7171

7272
`skuba lint` runs concurrent processes by default.

docs/cli/lint.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ This command should be run in CI to verify that [`skuba format`] was applied and
4343
```shell
4444
skuba lint
4545

46-
# [Prettier] Checking formatting...
47-
# [Prettier] All matched files use Prettier code style!
48-
# [Prettier] prettier --check . exited with code 0
49-
# [ESLint ] eslint --ext=js,ts,tsx --report-unused-disable-directives . exited with code 0
50-
# [tsc ] TSFILE: /Users/rling/Code/seek-jobs/indie-ryanair-service/lib/tsconfig.tsbuildinfo
51-
# [tsc ] tsc --noEmit exited with code 0
46+
# Prettier | Checking formatting...
47+
# Prettier | All matched files use Prettier code style!
48+
# Prettier | prettier --check . exited with code 0
49+
# ESLint | eslint --ext=js,ts,tsx --report-unused-disable-directives . exited with code 0
50+
# tsc | TSFILE: /Users/rling/Code/seek-jobs/indie-ryanair-service/lib/tsconfig.tsbuildinfo
51+
# tsc | tsc --noEmit exited with code 0
5252
```
5353

5454
`skuba lint` runs concurrent processes by default.

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
"sideEffects": false,
2222
"license": "MIT",
2323
"scripts": {
24-
"build": "yarn skuba build && scripts/postbuild.sh",
24+
"build": "ts-node --transpile-only src/skuba build && scripts/postbuild.sh",
2525
"deploy": "scripts/deploy.sh",
2626
"format": "yarn skuba format",
2727
"lint": "yarn skuba lint",
2828
"release": "yarn build && changeset publish",
2929
"stage": "changeset version && yarn format",
30-
"skuba": "ts-node src/skuba",
30+
"skuba": "ts-node --transpile-only src/skuba build && node lib/skuba",
3131
"test": "yarn skuba test",
3232
"test:watch": "yarn skuba test --watch",
3333
"test:template": "scripts/test-template.sh"
@@ -57,7 +57,7 @@
5757
"dependencies": {
5858
"@types/jest": "^27.0.1",
5959
"chalk": "^4.1.0",
60-
"concurrently": "^6.0.0",
60+
"concurrently": "^6.2.1",
6161
"ejs": "^3.1.6",
6262
"enquirer": "^2.3.6",
6363
"eslint": "^7.27.0",

src/cli/lint.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ describe('lint', () => {
4949
},
5050
Object {
5151
"maxProcesses": "REDACTED",
52+
"prefix": "{name} |",
5253
},
5354
]
5455
`);
@@ -81,6 +82,7 @@ describe('lint', () => {
8182
},
8283
Object {
8384
"maxProcesses": "REDACTED",
85+
"prefix": "{name} |",
8486
},
8587
]
8688
`);

src/utils/exec.ts

+18-5
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,22 @@ export const createExec =
110110

111111
export const exec: Exec = (command, ...args) => runCommand(command, args);
112112

113-
export const execConcurrently = async (commands: ExecConcurrentlyCommand[]) => {
114-
const maxNameLength = commands.reduce(
115-
(length, command) => Math.max(length, command.name.length),
116-
0,
117-
);
113+
export const execConcurrently = async (
114+
commands: ExecConcurrentlyCommand[],
115+
/**
116+
* A set length to pad names to.
117+
*
118+
* If this argument is not supplied, the length will be inferred from the
119+
* longest name in `commands`.
120+
*/
121+
nameLength?: number,
122+
) => {
123+
const maxNameLength =
124+
nameLength ??
125+
commands.reduce(
126+
(length, command) => Math.max(length, command.name.length),
127+
0,
128+
);
118129

119130
try {
120131
await concurrently(
@@ -127,6 +138,8 @@ export const execConcurrently = async (commands: ExecConcurrentlyCommand[]) => {
127138
{
128139
// Run serially on Buildkite, where we often use puny agents.
129140
maxProcesses: process.env.BUILDKITE ? 1 : 0,
141+
// Use a minimalist logging prefix.
142+
prefix: '{name} |',
130143
},
131144
);
132145
} catch (err: unknown) {

yarn.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -2440,7 +2440,7 @@ [email protected]:
24402440
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
24412441
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
24422442

2443-
concurrently@^6.0.0:
2443+
concurrently@^6.2.1:
24442444
version "6.2.1"
24452445
resolved "https://registry.yarnpkg.com/concurrently/-/concurrently-6.2.1.tgz#d880fc1d77559084732fa514092a3d5109a0d5bf"
24462446
integrity sha512-emgwhH+ezkuYKSHZQ+AkgEpoUZZlbpPVYCVv7YZx0r+T7fny1H03r2nYRebpi2DudHR4n1Rgbo2YTxKOxVJ4+g==

0 commit comments

Comments
 (0)