mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-26 11:02:01 -04:00
chore: compile pnpm CLI bundle before tests that use it (#11059)
Packages whose tests spawn the local pnpm CLI (pnpm/bin/pnpm.mjs) need the bundle (pnpm/dist/pnpm.mjs) to exist. Add `pnpm --filter pnpm run compile` to their test scripts so the bundle is built before tests run.
This commit is contained in:
@@ -15,6 +15,19 @@ import { writeJsonFile } from 'write-json-file'
|
||||
|
||||
const CLI_PKG_NAME = 'pnpm'
|
||||
|
||||
// Packages whose tests spawn the local pnpm CLI binary (pnpm/bin/pnpm.mjs)
|
||||
// and therefore need the CLI bundle (pnpm/dist/pnpm.mjs) to be built first.
|
||||
const PKGS_NEEDING_CLI_COMPILE = new Set([
|
||||
'@pnpm/building.commands',
|
||||
'@pnpm/cache.commands',
|
||||
'@pnpm/deps.inspection.commands',
|
||||
'@pnpm/exec.commands',
|
||||
'@pnpm/lockfile.make-dedicated-lockfile',
|
||||
'@pnpm/releasing.commands',
|
||||
'@pnpm/releasing.exportable-manifest',
|
||||
'@pnpm/store.commands',
|
||||
])
|
||||
|
||||
export default async (workspaceDir: string) => { // eslint-disable-line
|
||||
const workspaceManifest = await readWorkspaceManifest(workspaceDir)!
|
||||
const pnpmManifest = loadJsonFileSync<ProjectManifest>(path.join(workspaceDir, 'pnpm/package.json'))
|
||||
@@ -299,6 +312,9 @@ async function updateManifest (workspaceDir: string, manifest: ProjectManifest,
|
||||
}
|
||||
break
|
||||
}
|
||||
if (manifest.name && PKGS_NEEDING_CLI_COMPILE.has(manifest.name)) {
|
||||
scripts.test = 'pnpm run compile && pnpm --filter pnpm run compile && pnpm run .test'
|
||||
}
|
||||
// Clean up old underscore-prefixed script names
|
||||
delete scripts._test
|
||||
delete scripts._compile
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
"scripts": {
|
||||
"lint": "eslint src/**/*.ts test/**/*.ts",
|
||||
"compile": "rimraf tsconfig.tsbuildinfo lib && tsc --build",
|
||||
"test": "pnpm run compile && cross-env NODE_OPTIONS=--experimental-vm-modules jest"
|
||||
"test": "pnpm run compile && pnpm --filter pnpm run compile && cross-env NODE_OPTIONS=--experimental-vm-modules jest"
|
||||
},
|
||||
"keywords": [
|
||||
"pnpm",
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"test": "pnpm run compile && pnpm run .test",
|
||||
"test": "pnpm run compile && pnpm --filter pnpm run compile && pnpm run .test",
|
||||
"prepublishOnly": "pnpm run compile",
|
||||
"compile": "tsgo --build && pnpm run lint --fix",
|
||||
".test": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules --disable-warning=ExperimentalWarning --disable-warning=DEP0169\" jest"
|
||||
|
||||
2
cache/commands/package.json
vendored
2
cache/commands/package.json
vendored
@@ -26,7 +26,7 @@
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"test": "pnpm run compile && pnpm run .test",
|
||||
"test": "pnpm run compile && pnpm --filter pnpm run compile && pnpm run .test",
|
||||
"prepublishOnly": "pnpm run compile",
|
||||
"compile": "tsgo --build && pnpm run lint --fix",
|
||||
".test": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules --disable-warning=ExperimentalWarning --disable-warning=DEP0169\" jest"
|
||||
|
||||
2
deps/inspection/commands/package.json
vendored
2
deps/inspection/commands/package.json
vendored
@@ -25,7 +25,7 @@
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"test": "pnpm run compile && pnpm run .test",
|
||||
"test": "pnpm run compile && pnpm --filter pnpm run compile && pnpm run .test",
|
||||
"prepublishOnly": "pnpm run compile",
|
||||
"compile": "tsgo --build && pnpm run lint --fix",
|
||||
".test": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules --disable-warning=ExperimentalWarning --disable-warning=DEP0169\" jest"
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"test": "pnpm run compile && pnpm run .test",
|
||||
"test": "pnpm run compile && pnpm --filter pnpm run compile && pnpm run .test",
|
||||
"prepublishOnly": "pnpm run compile",
|
||||
"start": "tsgo --watch",
|
||||
"compile": "tsgo --build && pnpm run lint --fix",
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
"bin": "./bin/make-dedicated-lockfile.js",
|
||||
"scripts": {
|
||||
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"test": "pnpm run compile && pnpm run .test",
|
||||
"test": "pnpm run compile && pnpm --filter pnpm run compile && pnpm run .test",
|
||||
"prepublishOnly": "pnpm run compile",
|
||||
"compile": "tsgo --build && pnpm run lint --fix",
|
||||
".test": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules --disable-warning=ExperimentalWarning --disable-warning=DEP0169\" jest"
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
"scripts": {
|
||||
"start": "tsgo --watch",
|
||||
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"test": "pnpm run compile && pnpm run .test",
|
||||
"test": "pnpm run compile && pnpm --filter pnpm run compile && pnpm run .test",
|
||||
"prepublishOnly": "pnpm run compile",
|
||||
"compile": "tsgo --build && pnpm run lint --fix",
|
||||
".test": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules --disable-warning=ExperimentalWarning --disable-warning=DEP0169\" jest"
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"test": "pnpm run compile && pnpm run .test",
|
||||
"test": "pnpm run compile && pnpm --filter pnpm run compile && pnpm run .test",
|
||||
"prepublishOnly": "pnpm run compile",
|
||||
"compile": "tsgo --build && pnpm run lint --fix",
|
||||
".test": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules --disable-warning=ExperimentalWarning --disable-warning=DEP0169\" jest"
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"test": "pnpm run compile && pnpm run .test",
|
||||
"test": "pnpm run compile && pnpm --filter pnpm run compile && pnpm run .test",
|
||||
"prepublishOnly": "pnpm run compile",
|
||||
"compile": "tsgo --build && pnpm run lint --fix",
|
||||
".test": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules --disable-warning=ExperimentalWarning --disable-warning=DEP0169\" jest"
|
||||
|
||||
Reference in New Issue
Block a user