Skip to content

Commit

Permalink
Prefix workspace commands with workspace name
Browse files Browse the repository at this point in the history
  • Loading branch information
peterlebrun committed Jan 16, 2019
1 parent fb03788 commit d2324be
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 6 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ Please add one entry in this file for each change in Yarn's behavior. Use the sa

## Master

- Prefix `yarn workspaces run` output with workspace name

- Improves PnP compatibility with Node 6

[#6871](https://github.com/yarnpkg/yarn/pull/6871) - [**Robert Jackson**](https://github.com/rwjblue)

- Fixes PnP detection with workspaces (`installConfig` is now read at the top-level)

[#6878](https://github.com/yarnpkg/yarn/pull/6878) - [**Maël Nison**](https://twitter.com/arcanis)

- Fixes an interaction between `yarn pack` and bundled dependencies

[#6908](https://github.com/yarnpkg/yarn/pull/6908) - [**Travis Hoover**](https://twitter.com/thoov)
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"ssri": "^5.3.0",
"strip-ansi": "^4.0.0",
"strip-bom": "^3.0.0",
"strong-log-transformer": "2.1.0",
"tar-fs": "^1.16.0",
"tar-stream": "^1.6.1",
"uuid": "^3.0.1",
Expand Down
3 changes: 3 additions & 0 deletions packages/pkg-tests/pkg-tests-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@
"super-resolve": "^1.0.0",
"tar-fs": "^1.16.0",
"tmp": "^0.0.33"
},
"scripts": {
"test-script": "echo pkg-tests-core test-script"
}
}
3 changes: 2 additions & 1 deletion packages/pkg-tests/pkg-tests-fixtures/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "pkg-tests-fixtures",
"version": "1.0.0",
"scripts": {
"copy-index": "find packages -type d -mindepth 1 -maxdepth 1 | while read pkg; do cp default-index.js \"$pkg\/index.js\"; done"
"copy-index": "find packages -type d -mindepth 1 -maxdepth 1 | while read pkg; do cp default-index.js \"$pkg\/index.js\"; done",
"test-script": "echo pkg-tests-fixtures test-script"
}
}
3 changes: 3 additions & 0 deletions packages/pkg-tests/pkg-tests-specs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
"fs-extra": "^7.0.0",
"pkg-tests-core": "1.0.0",
"semver": "^5.6.0"
},
"scripts": {
"test-script": "echo pkg-tests-specs test-script"
}
}
3 changes: 2 additions & 1 deletion src/cli/commands/workspaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ export async function runScript(config: Config, reporter: Reporter, flags: Objec
const {loc} = workspaces[workspaceName];

await child.spawn(NODE_BIN_PATH, [YARN_BIN_PATH, ...rest], {
stdio: 'inherit',
stdio: 'pipe',
cwd: loc,
workspaceName
});
}
} catch (err) {
Expand Down
19 changes: 18 additions & 1 deletion src/util/child.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import {promisify} from './promise.js';

const child = require('child_process');

const logTransformer = require('strong-log-transformer');
const chalk = require('chalk');
const colors = ["red", "yellow", "green", "cyan", "blue", "magenta", "white", "gray"];
const workspaceColors = {};

export const queue = new BlockingQueue('child', constants.CHILD_CONCURRENCY);

// TODO: this uid check is kinda whack
Expand Down Expand Up @@ -116,7 +121,19 @@ export function spawn(
}

if (proc.stdout) {
proc.stdout.on('data', updateStdout);
// Prefix output with workspace name, if we have it
if (opts.workspaceName) {
if (!workspaceColors[opts.workspaceName]) {
const randInt = Math.floor(Math.random() * colors.length);
// Make sure that we are consistent
workspaceColors[opts.workspaceName] = colors[randInt];
}
let wsColor = chalk[workspaceColors[opts.workspaceName]];
let tag = `${wsColor.bold(opts.workspaceName)}:`;
proc.stdout.pipe(logTransformer({tag})).pipe(process.stdout);
} else {
proc.stdout.on('data', updateStdout);
}
}

processingDone = true;
Expand Down
16 changes: 15 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2387,6 +2387,11 @@ domexception@^1.0.1:
dependencies:
webidl-conversions "^4.0.2"

duplexer@^0.1.1:
version "0.1.1"
resolved "https://artifactory-eng.cargurus.com/artifactory/api/npm/npm-registry/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1"
integrity sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=

duplexify@^3.5.0, duplexify@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/duplexify/-/duplexify-3.6.0.tgz#592903f5d80b38d037220541264d69a198fb3410"
Expand Down Expand Up @@ -7077,6 +7082,15 @@ [email protected], strip-json-comments@~2.0.1:
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"
integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo=

[email protected]:
version "2.1.0"
resolved "https://artifactory-eng.cargurus.com/artifactory/api/npm/npm-registry/strong-log-transformer/-/strong-log-transformer-2.1.0.tgz#0f5ed78d325e0421ac6f90f7f10e691d6ae3ae10"
integrity sha1-D17XjTJeBCGsb5D38Q5pHWrjrhA=
dependencies:
duplexer "^0.1.1"
minimist "^1.2.0"
through "^2.3.4"

supports-color@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"
Expand Down Expand Up @@ -7231,7 +7245,7 @@ [email protected], through2@^2.0.0, through2@^2.0.1, through2@^2.0.3, through2@~2.0.0
readable-stream "^2.1.5"
xtend "~4.0.1"

through@^2.3.6:
through@^2.3.4, through@^2.3.6:
version "2.3.8"
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=
Expand Down

0 comments on commit d2324be

Please sign in to comment.