Skip to content

Commit

Permalink
Fix test on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
bertdeblock committed Nov 18, 2024
1 parent 1cb6b92 commit 2d99076
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ jobs:
- run: pnpm lint

test:
needs:
- lint
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
Expand Down
8 changes: 5 additions & 3 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { findUp } from "find-up";
import { pathToFileURL } from "node:url";
import { DocumentName, type File } from "./types.js";

type Config = {
export type Config = {
hooks?: {
postGenerate?: (info: {
documentName: DocumentName;
Expand Down Expand Up @@ -31,8 +31,10 @@ export async function getConfig(cwd: string): Promise<Config> {

try {
config = (await import(pathToFileURL(path).toString())).default;
} catch {
throw new Error(`Could not import gember config file at "${path}".`);
} catch (cause) {
throw new Error(`Could not import gember config file at "${path}".`, {

Check failure on line 35 in src/config.ts

View workflow job for this annotation

GitHub Actions / test (latest, windows-latest)

test/config.test.ts > supports a `gember.config.js` file

Error: Could not import gember config file at "C:\Users\RUNNER~1\AppData\Local\Temp\tmp-43246wK2NbUUECxu\gember.config.js". ❯ Module.getConfig src/config.ts:35:11 ❯ test/config.test.ts:20:18 Caused by: Caused by: Error: Failed to load url C:/Users/RUNNER%7E1/AppData/Local/Temp/tmp-43246wK2NbUUECxu/gember.config.js (resolved id: C:/Users/RUNNER%7E1/AppData/Local/Temp/tmp-43246wK2NbUUECxu/gember.config.js). Does the file exist? ❯ loadAndTransform node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:51920:17

Check failure on line 35 in src/config.ts

View workflow job for this annotation

GitHub Actions / test (latest, windows-latest)

test/config.test.ts > supports a `gember.config.cjs` file

Error: Could not import gember config file at "C:\Users\RUNNER~1\AppData\Local\Temp\tmp-4324WXr28T0Pc2HO\gember.config.cjs". ❯ Module.getConfig src/config.ts:35:11 ❯ test/config.test.ts:35:18 Caused by: Caused by: Error: Failed to load url C:/Users/RUNNER%7E1/AppData/Local/Temp/tmp-4324WXr28T0Pc2HO/gember.config.cjs (resolved id: C:/Users/RUNNER%7E1/AppData/Local/Temp/tmp-4324WXr28T0Pc2HO/gember.config.cjs). Does the file exist? ❯ loadAndTransform node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:51920:17

Check failure on line 35 in src/config.ts

View workflow job for this annotation

GitHub Actions / test (latest, windows-latest)

test/config.test.ts > supports a `gember.config.mjs` file

Error: Could not import gember config file at "C:\Users\RUNNER~1\AppData\Local\Temp\tmp-4324QuRHmK0G3rOU\gember.config.mjs". ❯ Module.getConfig src/config.ts:35:11 ❯ test/config.test.ts:50:18 Caused by: Caused by: Error: Failed to load url C:/Users/RUNNER%7E1/AppData/Local/Temp/tmp-4324QuRHmK0G3rOU/gember.config.mjs (resolved id: C:/Users/RUNNER%7E1/AppData/Local/Temp/tmp-4324QuRHmK0G3rOU/gember.config.mjs). Does the file exist? ❯ loadAndTransform node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:51920:17
cause,
});
}

if (config === undefined) {
Expand Down
9 changes: 7 additions & 2 deletions test/blueprints/v2-addon-hooks/gember.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import { writeFile } from "node:fs/promises";
import { dirname, join, relative } from "node:path";
import { EOL } from "node:os";
import { dirname, join, relative, sep } from "node:path";
import { fileURLToPath } from "node:url";

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

for (const file of info.files) {
// Support Windows:
file.content = file.content.replace(EOL, "\n");

// Because the absolute path is different on each machine:
file.path = relative("test/output", file.path);
file.path = relative("test/output", file.path).split(sep).join("/");
}

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

0 comments on commit 2d99076

Please sign in to comment.