Skip to content

Commit

Permalink
fix(core): use binjumper to work-around 'Terminate batch job' prompts…
Browse files Browse the repository at this point in the history
… on Windows (#1808)

* fix(core): use binjumper to work-around 'Terminate batch job' prompts on Windows

* chore: changelog

Co-authored-by: Maël Nison <[email protected]>
  • Loading branch information
merceyz and arcanis authored Sep 30, 2020
1 parent 59adb5b commit 97a66ff
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 3 deletions.
10 changes: 10 additions & 0 deletions .pnp.js

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

Binary file not shown.
32 changes: 32 additions & 0 deletions .yarn/versions/cbb2813a.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
releases:
"@yarnpkg/cli": patch
"@yarnpkg/core": patch
"@yarnpkg/plugin-dlx": patch
"@yarnpkg/plugin-essentials": patch
"@yarnpkg/plugin-exec": patch
"@yarnpkg/plugin-init": patch
"@yarnpkg/plugin-workspace-tools": patch
"@yarnpkg/pnpify": patch

declined:
- "@yarnpkg/plugin-compat"
- "@yarnpkg/plugin-constraints"
- "@yarnpkg/plugin-file"
- "@yarnpkg/plugin-git"
- "@yarnpkg/plugin-github"
- "@yarnpkg/plugin-http"
- "@yarnpkg/plugin-interactive-tools"
- "@yarnpkg/plugin-link"
- "@yarnpkg/plugin-node-modules"
- "@yarnpkg/plugin-npm"
- "@yarnpkg/plugin-npm-cli"
- "@yarnpkg/plugin-pack"
- "@yarnpkg/plugin-patch"
- "@yarnpkg/plugin-pnp"
- "@yarnpkg/plugin-stage"
- "@yarnpkg/plugin-typescript"
- "@yarnpkg/plugin-version"
- vscode-zipfs
- "@yarnpkg/builder"
- "@yarnpkg/doctor"
- "@yarnpkg/pnp"
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@

### CLI

- The `yarn tag` commands have been ported over from Yarn Classic as `yarn npm tag`.
- The `yarn tag` set of commands has been ported over from Yarn Classic as `yarn npm tag`.
- Running `yarn info` will now print many information about your dependencies. Various options are available to tweak the output, including `--json`. Plugin authors can provide their own information sections via the `fetchPackageInfo` hook.
- Running `yarn stage` with the `-r,--reset` flag will now unstage all changes that seem related to Yarn.
- All commands now document each of their options (run `yarn add -h` to see an example).
- Publish registry errors will now be reported as is rather than being collapsed into a generic error message.
- A native binary jumper will now be used on Windows to avoid the `Terminate batch job (Y/N)?` prompts when invoking dependency binaries.

### Installs

Expand Down
1 change: 1 addition & 0 deletions packages/yarnpkg-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"@yarnpkg/parsers": "workspace:^2.2.0",
"@yarnpkg/pnp": "workspace:^2.2.1",
"@yarnpkg/shell": "workspace:^2.2.0",
"binjumper": "^0.1.0",
"camelcase": "^5.3.1",
"chalk": "^3.0.0",
"ci-info": "^2.0.0",
Expand Down
11 changes: 8 additions & 3 deletions packages/yarnpkg-core/sources/scriptUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import {CwdFS, Filename, NativePath, PortablePath, ZipOpenFS} from '@yarnpkg/fsl
import {xfs, npath, ppath, toFilename} from '@yarnpkg/fslib';
import {getLibzipPromise} from '@yarnpkg/libzip';
import {execute} from '@yarnpkg/shell';
import {getBinjumper} from "binjumper";
import capitalize from 'lodash/capitalize';
import pLimit from 'p-limit';

import {PassThrough, Readable, Writable} from 'stream';

import {Configuration} from './Configuration';
Expand All @@ -29,8 +29,13 @@ enum PackageManager {
}

async function makePathWrapper(location: PortablePath, name: Filename, argv0: NativePath, args: Array<string> = []) {
if (process.platform === `win32`)
await xfs.writeFilePromise(ppath.format({dir: location, name, ext: `.cmd`}), `@"${argv0}" ${args.map(arg => `"${arg.replace(`"`, `""`)}"`).join(` `)} %*\n`);
if (process.platform === `win32`) {
await Promise.all([
xfs.writeFilePromise(ppath.format({dir: location, name, ext: `.exe`}), getBinjumper()),
xfs.writeFilePromise(ppath.format({dir: location, name, ext: `.exe.info`}), [argv0, ...args].join(`\n`)),
xfs.writeFilePromise(ppath.format({dir: location, name, ext: `.cmd`}), `@"${argv0}" ${args.map(arg => `"${arg.replace(`"`, `""`)}"`).join(` `)} %*\n`),
]);
}

await xfs.writeFilePromise(ppath.join(location, name), `#!/bin/sh\nexec "${argv0}" ${args.map(arg => `'${arg.replace(/'/g, `'"'"'`)}'`).join(` `)} "$@"\n`);
await xfs.chmodPromise(ppath.join(location, name), 0o755);
Expand Down
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5497,6 +5497,7 @@ __metadata:
"@yarnpkg/plugin-pnp": "workspace:^2.2.1"
"@yarnpkg/pnp": "workspace:^2.2.1"
"@yarnpkg/shell": "workspace:^2.2.0"
binjumper: ^0.1.0
camelcase: ^5.3.1
chalk: ^3.0.0
ci-info: ^2.0.0
Expand Down Expand Up @@ -7682,6 +7683,13 @@ __metadata:
languageName: node
linkType: hard

"binjumper@npm:^0.1.0":
version: 0.1.0
resolution: "binjumper@npm:0.1.0"
checksum: 223983fc10c44aa90e257aed352da70bf119d9ca015adfd101f6ef201cac4dd6ba3a65630aa52f6022da342a07d2d3f6fc7420940501f5b1c02f0a69cbab9312
languageName: node
linkType: hard

"bl@npm:^1.0.0":
version: 1.2.2
resolution: "bl@npm:1.2.2"
Expand Down

0 comments on commit 97a66ff

Please sign in to comment.