Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows support WIP #3448

Merged
merged 5 commits into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/zero-schema/src/build-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ async function main() {

const dirname = path.dirname(fileURLToPath(import.meta.url));
const absoluteConfigPath = path.resolve(config.schema.path);
const relativePath = path.join(
let relativePath = path.join(
path.relative(dirname, path.dirname(absoluteConfigPath)),
path.basename(absoluteConfigPath),
);

// tsImport doesn't expect to receive slashes in the Windows format when running
// on Windows. They need to be converted to *nix format.
relativePath = relativePath.replace(/\\/g, "/");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why'd you need this change? I would have thought that the slashes were correct due to the use of path.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what gets passed into the tsImport

..\..\..\..\..\..\..\..\..\apps\app\schema
file:///C:/zero/node_modules/.pnpm/@[email protected]/node_modules/@rocicorp/zero/out/zero-schema/src/build-schema.js

I can't find it now in the tsx codebase. But I'm guessing it can't deal with the mismatched slashes. I kinda gave up some time ago trying to understand how node handles paths and the differences between Windows and Linux/OSX

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment on the line. Something like:

// tsImport doesn't expect to receive slashes in the Windows format when running
// on windows. They need to be converted to *nix format.


try {
const module = await tsImport(relativePath, import.meta.url);
await writeFile(config.schema.output, await stringifySchema(module));
Expand Down
2 changes: 2 additions & 0 deletions packages/zero/src/zero-cache-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ async function main() {
log(`Running ${buildSchemaScript}.`);
schemaProcess = spawn(buildSchemaScript, buildSchemaArgs ?? [], {
stdio: 'inherit',
shell: true,
});

schemaProcess.on('exit', (code: number) => {
Expand All @@ -94,6 +95,7 @@ async function main() {
);
zeroCacheProcess = spawn(zeroCacheScript, zeroCacheArgs || [], {
stdio: 'inherit',
shell: true,
});
zeroCacheProcess.on('exit', () => {
logError(`${zeroCacheScript} exited. Exiting.`);
Expand Down
Loading