mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 02:48:50 +00:00
### What does this PR do? Adds support for `publicHoistPattern` in `bunfig.toml` and `public-hoist-pattern` from `.npmrc`. This setting allows you to select transitive packages to hoist to the root node_modules making them available for all workspace packages. ```toml [install] # can be a string publicHoistPattern = "@types*" # or an array publicHoistPattern = [ "@types*", "*eslint*" ] ``` `publicHoistPattern` only affects the isolated linker. --- Adds `hoistPattern`. `hoistPattern` is the same as `publicHoistPattern`, but applies to the `node_modules/.bun/node_modules` directory instead of the root node_modules. Also the default value of `hoistPattern` is `*` (everything is hoisted to `node_modules/.bun/node_modules` by default). --- Fixes a determinism issue constructing the `node_modules/.bun/node_modules` directory. --- closes #23481 closes #6160 closes #23548 ### How did you verify your code works? Added tests for - [x] only include patterns - [x] only exclude patterns - [x] mix of include and exclude - [x] errors for unexpected expression types - [x] excluding direct dependency (should still include) - [x] match all with `*` - [x] string and array expression types --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
17 lines
724 B
TypeScript
17 lines
724 B
TypeScript
import testHelpers from "bun:internal-for-testing";
|
|
import { expect, test } from "bun:test";
|
|
const { escapeRegExp, escapeRegExpForPackageNameMatching } = testHelpers;
|
|
|
|
test("escapeRegExp", () => {
|
|
expect(escapeRegExp("\\ ^ $ * + ? . ( ) | { } [ ]")).toBe("\\\\ \\^ \\$ \\* \\+ \\? \\. \\( \\) \\| \\{ \\} \\[ \\]");
|
|
expect(escapeRegExp("foo - bar")).toBe("foo \\x2d bar");
|
|
});
|
|
|
|
test("escapeRegExpForPackageName", () => {
|
|
// same as the other but '*' becomes '.*' instead of '\*'
|
|
expect(escapeRegExpForPackageNameMatching("foo - bar*")).toBe("foo \\x2d bar.*");
|
|
expect(escapeRegExpForPackageNameMatching("\\ ^ $ * + ? . ( ) | { } [ ]")).toBe(
|
|
"\\\\ \\^ \\$ .* \\+ \\? \\. \\( \\) \\| \\{ \\} \\[ \\]",
|
|
);
|
|
});
|