From a640584a585114c122c4f4fa49860373e945195f Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Mon, 7 Dec 2020 13:32:56 +0100 Subject: [PATCH] fix: move binary file declaration from runtime to repl (#10925) --- CHANGELOG.md | 2 +- packages/jest-repl/package.json | 8 ++++++-- packages/jest-runtime/package.json | 4 +--- scripts/buildUtils.js | 12 ++++++++++++ yarn.lock | 3 +-- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8906b1b307b6..6298a679b4ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,7 +51,7 @@ - `[jest-haste-map]` [**BREAKING**] Migrate to ESM ([#10875](https://github.com/facebook/jest/pull/10875)) - `[jest-haste-map]` [**BREAKING**] Remove support for deprecated option `ignorePattern` as function ([#10348](https://github.com/facebook/jest/pull/10348)) - `[jest-jasmine2]` [**BREAKING**] Migrate to ESM ([#10906](https://github.com/facebook/jest/pull/10906)) -- `[jest-repl, jest-runtime]` [**BREAKING**] Move the `jest-runtime` CLI into `jest-repl` ([#10016](https://github.com/facebook/jest/pull/10016)) +- `[jest-repl, jest-runtime]` [**BREAKING**] Move the `jest-runtime` CLI into `jest-repl` ([#10016](https://github.com/facebook/jest/pull/10016) & [#10925](https://github.com/facebook/jest/pull/10925)) - `[jest-resolve]` [**BREAKING**] Migrate to ESM ([#10688](https://github.com/facebook/jest/pull/10688)) - `[jest-resolve-dependencies]` [**BREAKING**] Migrate to ESM ([#10876](https://github.com/facebook/jest/pull/10876)) - `[jest-mock]` [**BREAKING**] Migrate to ESM ([#10887](https://github.com/facebook/jest/pull/10887)) diff --git a/packages/jest-repl/package.json b/packages/jest-repl/package.json index 13494bbdbe34..679ced840153 100644 --- a/packages/jest-repl/package.json +++ b/packages/jest-repl/package.json @@ -12,7 +12,8 @@ "exports": { ".": "./build/index.js", "./package.json": "./package.json", - "./bin/jest-repl": "./bin/jest-repl.js" + "./bin/jest-repl": "./bin/jest-repl.js", + "./bin/jest-runtime-cli": "./bin/jest-runtime-cli.js" }, "dependencies": { "@jest/console": "^27.0.0-next.0", @@ -32,7 +33,10 @@ "@types/yargs": "^15.0.0", "execa": "^5.0.0" }, - "bin": "./bin/jest-repl.js", + "bin": { + "jest-repl": "./bin/jest-repl.js", + "jest-runtime": "./bin/jest-runtime-cli.js" + }, "engines": { "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" }, diff --git a/packages/jest-runtime/package.json b/packages/jest-runtime/package.json index f666ee518219..4d707e0d8a2f 100644 --- a/packages/jest-runtime/package.json +++ b/packages/jest-runtime/package.json @@ -11,8 +11,7 @@ "types": "./build/index.d.ts", "exports": { ".": "./build/index.js", - "./package.json": "./package.json", - "./bin/jest-runtime": "./bin/jest-runtime.js" + "./package.json": "./package.json" }, "dependencies": { "@jest/console": "^27.0.0-next.0", @@ -52,7 +51,6 @@ "jest-environment-node": "^27.0.0-next.0", "jest-snapshot-serializer-raw": "^1.1.0" }, - "bin": "./bin/jest-runtime.js", "engines": { "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" }, diff --git a/scripts/buildUtils.js b/scripts/buildUtils.js index 43a5e7fec6e3..7a886d2f706d 100644 --- a/scripts/buildUtils.js +++ b/scripts/buildUtils.js @@ -55,6 +55,18 @@ module.exports.getPackages = function getPackages() { }, `Package ${pkg.name} does not export correct files`, ); + + if (pkg.bin) { + Object.entries(pkg.bin).forEach(([binName, binPath]) => { + const fullBinPath = path.resolve(packageDir, binPath); + + if (!fs.existsSync(fullBinPath)) { + throw new Error( + `Binary in package ${pkg.name} with name "${binName}" at ${binPath} does not exist`, + ); + } + }); + } }); return packages; diff --git a/yarn.lock b/yarn.lock index 825919df8910..0edddbd7108d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11988,6 +11988,7 @@ fsevents@^1.2.7: yargs: ^16.0.3 bin: jest-repl: ./bin/jest-repl.js + jest-runtime: ./bin/jest-runtime-cli.js languageName: unknown linkType: soft @@ -12104,8 +12105,6 @@ fsevents@^1.2.7: slash: ^3.0.0 strip-bom: ^4.0.0 yargs: ^16.0.3 - bin: - jest-runtime: ./bin/jest-runtime.js languageName: unknown linkType: soft