mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-08 04:22:09 +00:00
Updates package manager detection to account for two lock files. All other managers will only have the one lock file. Bun, however, may have both a `bun.lockb` _and_ a `yarn.lock` file. To ensure bun is properly detected, the presence of `bun.lockb` with `yarn.lock` must occur before `yarn.lock` so we don't mistake the presence of a `yarn.lock` to mean "Yarn". This PR also adds a test for this situation in `fs-detectors`. The behavior is currently correct there, but was not tested initially. It is now to avoid future regressions.
36 lines
1.0 KiB
TypeScript
Vendored
36 lines
1.0 KiB
TypeScript
Vendored
import path from 'path';
|
|
import {
|
|
packageManagers,
|
|
detectFramework,
|
|
LocalFileSystemDetector,
|
|
} from '../src';
|
|
|
|
describe('package-managers', () => {
|
|
describe.each([
|
|
['50-no-specified-package-manager', 'yarn'],
|
|
['51-npm-with-lockfile', 'npm'],
|
|
['52-npm-with-corepack', 'npm'],
|
|
['53-yarn-with-lockfile', 'yarn'],
|
|
['54-yarn-with-corepack', 'yarn'],
|
|
['55-pnpm-with-lockfile', 'pnpm'],
|
|
['56-pnpm-with-corepack', 'pnpm'],
|
|
['57-bun-with-lockfile', 'bun'],
|
|
['58-bun-with-corepack', 'bun'],
|
|
['59-bun-with-binary-and-readable-lockfile', 'bun'],
|
|
])('with detectFramework', (fixturePath, frameworkSlug) => {
|
|
const testName = `should detect package manager '${frameworkSlug}' for ${fixturePath}`;
|
|
|
|
it(testName, async () => {
|
|
const fixture = path.join(__dirname, 'fixtures', fixturePath);
|
|
const fs = new LocalFileSystemDetector(fixture);
|
|
|
|
const result = await detectFramework({
|
|
fs,
|
|
frameworkList: packageManagers,
|
|
});
|
|
|
|
expect(result).toBe(frameworkSlug);
|
|
});
|
|
});
|
|
});
|