Skip to content

Commit eb65e65

Browse files
committed
Fix packages mode outside cwd
Resolves #2043
1 parent c265735 commit eb65e65

File tree

5 files changed

+38
-8
lines changed

5 files changed

+38
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Unreleased
22

3+
### Bug Fixes
4+
5+
- Fixed packages mode for packages outside of cwd (again), #2043.
6+
37
## v0.23.12 (2022-08-31)
48

59
### Features

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"@types/node": "14",
4141
"@typescript-eslint/eslint-plugin": "^5.36.1",
4242
"@typescript-eslint/parser": "^5.36.1",
43-
"@typestrong/fs-fixture-builder": "github:TypeStrong/fs-fixture-builder#b88cd06fe814614a0d924af9d10d04ff95a551de",
43+
"@typestrong/fs-fixture-builder": "github:TypeStrong/fs-fixture-builder#5a9486bc66f6e36988106685768396281f6cbc10",
4444
"c8": "^7.12.0",
4545
"esbuild": "^0.15.6",
4646
"eslint": "^8.23.0",

src/lib/utils/entry-point.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,8 @@ function deriveRootDir(packageGlobPaths: string[]): string {
306306
const rootPaths = globs.flatMap((glob) =>
307307
filterMap(glob.set, (set) => {
308308
const stop = set.findIndex((part) => typeof part !== "string");
309-
return stop === -1 ? set.join("/") : set.slice(0, stop).join("/");
309+
const path = stop === -1 ? set : set.slice(0, stop);
310+
return `/${path.join("/")}`;
310311
})
311312
);
312313
return getCommonDirectory(rootPaths);

src/test/slow/entry-point.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { tempdirProject } from "@typestrong/fs-fixture-builder";
22
import { deepStrictEqual as equal, ok } from "assert";
33
import { join } from "path";
4+
import { tmpdir } from "os";
45
import { Application, EntryPointStrategy, TSConfigReader } from "../..";
56

67
const fixture = tempdirProject();
@@ -86,4 +87,28 @@ describe("Entry Points", () => {
8687
equal(entryPoints.length, 1);
8788
equal(entryPoints[0].version, void 0);
8889
});
90+
91+
it("Supports resolving packages outside of cwd", () => {
92+
const fixture = tempdirProject({ rootDir: tmpdir() });
93+
fixture.addJsonFile("tsconfig.json", {
94+
include: ["."],
95+
});
96+
fixture.addJsonFile("package.json", {
97+
main: "index.ts",
98+
});
99+
fixture.addFile("index.ts", "export function fromIndex() {}");
100+
fixture.write();
101+
102+
app.bootstrap({
103+
tsconfig: tsconfig,
104+
entryPoints: [fixture.cwd],
105+
entryPointStrategy: EntryPointStrategy.Packages,
106+
});
107+
108+
const entryPoints = app.getEntryPoints();
109+
fixture.rm();
110+
ok(entryPoints);
111+
equal(entryPoints.length, 1);
112+
equal(entryPoints[0].version, void 0);
113+
});
89114
});

0 commit comments

Comments
 (0)