fix bun path for workspace installs
This commit is contained in:
@@ -23,6 +23,14 @@ import {
|
||||
|
||||
let tempRoot: string;
|
||||
|
||||
function expectedBunExecutable(): string {
|
||||
if (path.basename(process.execPath) === 'bun') {
|
||||
return process.execPath;
|
||||
}
|
||||
const homeBun = path.join(os.homedir(), '.bun', 'bin', 'bun');
|
||||
return fs.existsSync(homeBun) ? homeBun : 'bun';
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'ejclaw-pkgmgr-'));
|
||||
execFileSyncMock.mockReset();
|
||||
@@ -105,11 +113,35 @@ describe('workspace package manager detection', () => {
|
||||
commandText: 'corepack pnpm install --frozen-lockfile',
|
||||
});
|
||||
expect(buildWorkspaceScriptCommand(bunRepo, 'build')).toMatchObject({
|
||||
file: 'bun',
|
||||
file: expectedBunExecutable(),
|
||||
args: ['run', 'build'],
|
||||
commandText: 'bun run build',
|
||||
});
|
||||
});
|
||||
|
||||
it('uses an absolute Bun executable when building Bun workspace commands', () => {
|
||||
const repoDir = path.join(tempRoot, 'bun-path');
|
||||
fs.mkdirSync(repoDir, { recursive: true });
|
||||
fs.writeFileSync(
|
||||
path.join(repoDir, 'package.json'),
|
||||
JSON.stringify({
|
||||
packageManager: 'bun@1.3.13',
|
||||
scripts: { build: 'tsc' },
|
||||
}),
|
||||
);
|
||||
fs.writeFileSync(path.join(repoDir, 'bun.lock'), '');
|
||||
|
||||
const scriptCommand = buildWorkspaceScriptCommand(repoDir, 'build');
|
||||
const installCommand = resolveWorkspaceInstallCommand(repoDir);
|
||||
|
||||
expect(path.isAbsolute(scriptCommand.file)).toBe(true);
|
||||
expect(scriptCommand.file).toBe(expectedBunExecutable());
|
||||
expect(installCommand).toMatchObject({
|
||||
file: expectedBunExecutable(),
|
||||
args: ['install', '--frozen-lockfile'],
|
||||
commandText: 'bun install --frozen-lockfile',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('workspace dependency installs', () => {
|
||||
|
||||
Reference in New Issue
Block a user