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

Fixed: For making TS notebook in Windows #444

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"scripts": {
"dev": "vite-node -w dev-server.mts",
"test": "vitest",
"prebuild": "rm -rf ./dist",
"prebuild": "pnpm dlx rimraf ./dist",
"build": "tsc && cp -R ./drizzle ./dist/drizzle && cp -R ./srcbook/examples ./dist/srcbook/examples && cp -R ./prompts ./dist/prompts && cp -R ./apps/templates ./dist/apps/templates",
"lint": "eslint . --max-warnings 0",
"check-types": "tsc",
Expand Down Expand Up @@ -45,7 +45,9 @@
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/ws": "^8.5.12",
"cpx": "^1.5.0",
"drizzle-kit": "^0.24.2",
"rimraf": "^6.0.1",
"vite": "^5.4.4",
"vite-node": "^2.0.5",
"vitest": "^2.0.5"
Expand Down
12 changes: 11 additions & 1 deletion packages/api/tsserver/tsservers.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { spawn } from 'child_process';
import { TsServer } from './tsserver.mjs';
import Path from 'node:path';

/**
* This object is responsible for managing multiple tsserver instances.
Expand Down Expand Up @@ -44,8 +45,17 @@ export class TsServers {
// created, the dependencies are not installed and thus this will
// shut down immediately. Make sure that we handle this case after
// package.json has finished installing its deps.
const child = spawn('npx', ['tsserver'], {

const tsserverPath = Path.resolve(
options.cwd,
'node_modules',
'bin',
process.platform === 'win32' ? 'tsserver.cmd' : 'tsserver',
);

const child = spawn(tsserverPath, [], {
cwd: options.cwd,
shell: true,
});

const server = new TsServer(child);
Expand Down
Loading