Skip to content

Commit

Permalink
Fix yarn behaviour when scripts are failing (#5497)
Browse files Browse the repository at this point in the history
* Add test case to check behaviour for failing scripts

See #5451

* Fixed babel compilation of Error classes for nodejs 4

Added babel-plugin-transform-builtin-extend

* We don't actually need YARN_SILENT here
  • Loading branch information
sth authored and arcanis committed Apr 5, 2018
1 parent d4299be commit ffe9a64
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"plugins": [
["array-includes"],
["transform-inline-imports-commonjs"],
["transform-runtime", { "polyfill": true, "regenerator": false }]
["transform-runtime", { "polyfill": true, "regenerator": false }],
["transform-builtin-extend", { "globals": ["Error"] }]
]
},
"test": {
Expand Down
24 changes: 24 additions & 0 deletions __tests__/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,30 @@ test('yarn run <script> <strings that need escaping>', async () => {
expect(stdout.toString().trim()).toEqual(JSON.stringify(trickyStrings));
});

test('yarn run <failing script>', async () => {
const cwd = await makeTemp();

await fs.writeFile(
path.join(cwd, 'package.json'),
JSON.stringify({
license: 'MIT',
scripts: {false: 'false'},
}),
);

let stderr = null;
let err = null;
try {
await runYarn(['run', 'false'], {cwd});
} catch (e) {
stderr = e.stderr.trim();
err = e.code;
}

expect(err).toEqual(1);
expect(stderr).toEqual('error Command failed with exit code 1.');
});

test('yarn run in path need escaping', async () => {
const cwd = await makeTemp('special (chars)');

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"babel-eslint": "^7.2.3",
"babel-loader": "^6.2.5",
"babel-plugin-array-includes": "^2.0.3",
"babel-plugin-transform-builtin-extend": "^1.1.2",
"babel-plugin-transform-inline-imports-commonjs": "^1.0.0",
"babel-plugin-transform-runtime": "^6.4.3",
"babel-preset-env": "^1.6.0",
Expand Down
11 changes: 9 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,13 @@ babel-plugin-transform-async-to-generator@^6.22.0, babel-plugin-transform-async-
babel-plugin-syntax-async-functions "^6.8.0"
babel-runtime "^6.22.0"

babel-plugin-transform-builtin-extend@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-builtin-extend/-/babel-plugin-transform-builtin-extend-1.1.2.tgz#5e96fecf58b8fa1ed74efcad88475b2af3c9116e"
dependencies:
babel-runtime "^6.2.0"
babel-template "^6.3.0"

babel-plugin-transform-class-constructor-call@^6.24.1:
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-class-constructor-call/-/babel-plugin-transform-class-constructor-call-6.24.1.tgz#80dc285505ac067dcb8d6c65e2f6f11ab7765ef9"
Expand Down Expand Up @@ -1012,7 +1019,7 @@ babel-register@^6.26.0:
mkdirp "^0.5.1"
source-map-support "^0.4.15"

babel-runtime@^6.18.0, babel-runtime@^6.26.0:
babel-runtime@^6.18.0, babel-runtime@^6.2.0, babel-runtime@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe"
dependencies:
Expand All @@ -1036,7 +1043,7 @@ babel-template@^6.16.0, babel-template@^6.24.1:
babylon "^6.11.0"
lodash "^4.2.0"

babel-template@^6.26.0:
babel-template@^6.26.0, babel-template@^6.3.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.26.0.tgz#de03e2d16396b069f46dd9fff8521fb1a0e35e02"
dependencies:
Expand Down

0 comments on commit ffe9a64

Please sign in to comment.