Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Working for Windows#466

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
aakash-a-dev wants to merge10 commits intosrcbookdev:main
base:main
Choose a base branch
Loading
fromaakash-a-dev:Windows-ver

Conversation

aakash-a-dev
Copy link
Contributor

Fix:#297
Changes are made but requires to test on different OS.
Proof of work video here:
https://youtu.be/DC6lnsA_itU

finalEnv.PATH = newPaths + (existingPath ? ';' + existingPath : '');
}

console.log(`Executing command: ${finalCommand}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's remove the debug logs

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Removed

import Path from 'node:path';
import { spawn } from 'node:child_process';

interface NodeError extends Error {
code?: string;
}

/**
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove these comments

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Okay on it

@aakash-a-dev
Copy link
ContributorAuthor

Removed Debugging console & Comments made from my side

@aakash-a-dev
Copy link
ContributorAuthor

The updated code improves maintainability, efficiency, and cross-platform compatibility by centralizing executable resolution into a reusableExecutableResolver singleton. It leverageswhere on Windows andwhich on Unix to dynamically resolve paths, caching results to avoid redundant calls. This ensures consistent handling of executables likenode,tsx, andvite while prioritizing system executables (e.g., those inProgram Files). Platform-specific differences, such as handling.cmd files on Windows, are abstracted, reducing complexity in individual functions. This approach is cleaner, more scalable, and minimizes duplication, making the code easier to extend for additional commands or environments in the future.

args: process.platform === 'win32' ? ['vite', ...args] : args,
env: {
...env,
FORCE_COLOR: '1',
Copy link
Contributor

Choose a reason for hiding this comment

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

What's this?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

..env is for copying all the object, for creating in the following object although I added FORCE_COLOR: '1' Because it was getting difficult to find the response so for making it shine I added, I will remove it if you want

args: process.platform === 'win32' ? ['vite', ...args] : args,
env: {
...env,
FORCE_COLOR: '1',
Copy link
Contributor

Choose a reason for hiding this comment

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

What's this?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

For just making sure I can track that this log can easily noticeable while I was debugging, if you want I will remove FORCE_COLOR it was for me to make sure that it is logging

command:
process.platform === 'win32' ? 'npx.cmd' : Path.join(cwd, 'node_modules', '.bin', 'vite'),
cwd,
args: process.platform === 'win32' ? ['vite', ...args] : args,
Copy link
Contributor

Choose a reason for hiding this comment

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

So on windows, we need to call the command and then addvite as an arg? Feels like this isvite vite. Surprising

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Have to hard code it, only then it's running otherwise vite is not getting started, atleast for me it havn't

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Alien, Yes! While Vite code which was already there didn't started vite and thrown error, require to hard code this in the following way

export function spawnCall(options: SpawnCallRequestType) {
const { cwd, env, command, args, stdout, stderr, onExit, onError } = options;
const child = spawn(command, args, { cwd: cwd, env: env });
class ExecutableResolver {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit scared of this change. It's a pretty big refactor of an important part of the app.

I'm wondering if we can remove the new class implementation, and instead have some simple function based routing.

So first run a functionspawnCall which will call:
spawnCallUnix andspawnCallWindows based on the process.platform switch you do line 56.

That way the mac / unix code can stay the exact same which I think is safeer, and windows can have it's own code path.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Let me change it then!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@nichocharnichocharnichochar left review comments

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Creating ts srcbook on windows
2 participants
@aakash-a-dev@nichochar

[8]ページ先頭

©2009-2025 Movatter.jp