Skip to content

Commit c4fa57b

Browse files
committed
fix(release): canonicalize bundled npm verifier paths
1 parent 15277c9 commit c4fa57b

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

‎scripts/verify-bundled-npm-runtime.mjs‎

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createHash } from 'node:crypto';
22
import { createServer } from 'node:http';
3-
import { chmod, lstat, mkdtemp, mkdir, readFile, rm, writeFile } from 'node:fs/promises';
3+
import { chmod, lstat, mkdtemp, mkdir, readFile, realpath, rm, writeFile } from 'node:fs/promises';
44
import { tmpdir } from 'node:os';
55
import { dirname, join } from 'node:path';
66
import { fileURLToPath, pathToFileURL } from 'node:url';
@@ -84,19 +84,23 @@ async function verifyRealDependencyInstall({
8484
const fixtureRoot = join(scratchProject, 'registry-fixture');
8585
const packageRoot = join(fixtureRoot, 'package');
8686
const tarballPath = join(fixtureRoot, 'maka-fixture-bin-1.0.0.tgz');
87-
const projectRoot = join(scratchProject, 'project');
87+
const requestedProjectRoot = join(scratchProject, 'project');
88+
await Promise.all([
89+
mkdir(join(packageRoot, 'bin'), { recursive: true }),
90+
mkdir(join(requestedProjectRoot, 'node_modules'), { recursive: true }),
91+
mkdir(join(requestedProjectRoot, '.maka-runtime', 'home'), { recursive: true }),
92+
mkdir(join(requestedProjectRoot, '.maka-runtime', 'cache'), { recursive: true }),
93+
mkdir(join(requestedProjectRoot, '.maka-runtime', 'temp'), { recursive: true }),
94+
]);
95+
// Windows hosted runners commonly expose TEMP through an 8.3 alias such as
96+
// RUNNER~1. The producer owner canonicalizes cwd before spawn, so the
97+
// verifier must build its Permission Model allowlist from the same identity.
98+
const projectRoot = await realpath(requestedProjectRoot);
8899
const outputRoot = join(projectRoot, 'node_modules');
89100
const scratchRoot = join(projectRoot, '.maka-runtime');
90101
const homeRoot = join(scratchRoot, 'home');
91102
const cacheRoot = join(scratchRoot, 'cache');
92103
const tempRoot = join(scratchRoot, 'temp');
93-
await Promise.all([
94-
mkdir(join(packageRoot, 'bin'), { recursive: true }),
95-
mkdir(outputRoot, { recursive: true }),
96-
mkdir(homeRoot, { recursive: true }),
97-
mkdir(cacheRoot, { recursive: true }),
98-
mkdir(tempRoot, { recursive: true }),
99-
]);
100104
await Promise.all([
101105
writeFile(
102106
join(packageRoot, 'package.json'),

0 commit comments

Comments
 (0)