mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-10 12:57:47 +00:00
This PR removes `npm bin` in favor of a custom implementation since the command will be removed in npm 9. - Related to https://github.com/npm/statusboard/issues/537
47 lines
1.7 KiB
TypeScript
Vendored
47 lines
1.7 KiB
TypeScript
Vendored
import { join, parse } from 'path';
|
|
import { getNodeBinPath } from '../src';
|
|
|
|
describe('Test `getNodeBinPath()`', () => {
|
|
it('should work with npm7', async () => {
|
|
const cwd = join(__dirname, 'fixtures', '20-npm-7');
|
|
const result = await getNodeBinPath({ cwd });
|
|
expect(result).toBe(join(cwd, 'node_modules', '.bin'));
|
|
});
|
|
|
|
it('should work with yarn', async () => {
|
|
const cwd = join(__dirname, 'fixtures', '19-yarn-v2');
|
|
const result = await getNodeBinPath({ cwd });
|
|
expect(result).toBe(join(cwd, 'node_modules', '.bin'));
|
|
});
|
|
|
|
it('should work with npm 6', async () => {
|
|
const cwd = join(__dirname, 'fixtures', '08-yarn-npm/with-npm');
|
|
const result = await getNodeBinPath({ cwd });
|
|
expect(result).toBe(join(cwd, 'node_modules', '.bin'));
|
|
});
|
|
|
|
it('should work with npm workspaces', async () => {
|
|
const cwd = join(__dirname, 'fixtures', '21-npm-workspaces/a');
|
|
const result = await getNodeBinPath({ cwd });
|
|
expect(result).toBe(join(cwd, '..', 'node_modules', '.bin'));
|
|
});
|
|
|
|
it('should work with pnpm', async () => {
|
|
const cwd = join(__dirname, 'fixtures', '22-pnpm');
|
|
const result = await getNodeBinPath({ cwd });
|
|
expect(result).toBe(join(cwd, 'node_modules', '.bin'));
|
|
});
|
|
|
|
it('should work with pnpm workspaces', async () => {
|
|
const cwd = join(__dirname, 'fixtures', '23-pnpm-workspaces/c');
|
|
const result = await getNodeBinPath({ cwd });
|
|
expect(result).toBe(join(cwd, '..', 'node_modules', '.bin'));
|
|
});
|
|
|
|
it('should fallback to cwd if no lockfile found', async () => {
|
|
const cwd = parse(process.cwd()).root;
|
|
const result = await getNodeBinPath({ cwd });
|
|
expect(result).toBe(join(cwd, 'node_modules', '.bin'));
|
|
});
|
|
});
|