Skip to content

Commit d228b9d

Browse files
committed
Fix test on Windows
1 parent 1cb6b92 commit d228b9d

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ jobs:
1515
- run: pnpm lint
1616

1717
test:
18-
needs:
19-
- lint
18+
name: "test (node-version: ${{matrix.node-version}}, os: ${{matrix.os}})"
2019
runs-on: ${{matrix.os}}
2120
steps:
2221
- uses: actions/checkout@v4

src/config.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { findUp } from "find-up";
22
import { pathToFileURL } from "node:url";
33
import { DocumentName, type File } from "./types.js";
44

5-
type Config = {
5+
export type Config = {
66
hooks?: {
77
postGenerate?: (info: {
88
documentName: DocumentName;
@@ -31,8 +31,10 @@ export async function getConfig(cwd: string): Promise<Config> {
3131

3232
try {
3333
config = (await import(pathToFileURL(path).toString())).default;
34-
} catch {
35-
throw new Error(`Could not import gember config file at "${path}".`);
34+
} catch (cause) {
35+
throw new Error(`Could not import gember config file at "${path}".`, {
36+
cause,
37+
});
3638
}
3739

3840
if (config === undefined) {

test/blueprints/v2-addon-hooks/gember.config.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
import { writeFile } from "node:fs/promises";
2-
import { dirname, join, relative } from "node:path";
2+
import { EOL } from "node:os";
3+
import { dirname, join, relative, sep } from "node:path";
34
import { fileURLToPath } from "node:url";
45

6+
/** @type {import('../../../src/config.ts').Config} */
57
export default {
68
hooks: {
79
postGenerate: async (info) => {
810
const directory = dirname(fileURLToPath(import.meta.url));
911
const file = join(directory, "post-generate-info.json");
1012

1113
for (const file of info.files) {
14+
// Support Windows:
15+
file.content = file.content.replace(EOL, "\n");
16+
1217
// Because the absolute path is different on each machine:
13-
file.path = relative("test/output", file.path);
18+
file.path = relative("test/output", file.path).split(sep).join("/");
1419
}
1520

1621
await writeFile(file, JSON.stringify(info, null, 2));

0 commit comments

Comments
 (0)