From b33b7c3db61fd40abd462ebb338cd9e7079f3cef Mon Sep 17 00:00:00 2001 From: rizrmd Date: Tue, 28 May 2024 14:14:11 +0700 Subject: [PATCH] fix platform --- app/srv/ws/sync/code/parts/init/typings.ts | 5 ++++- pkgs/core/build.ts | 9 +++++++-- pkgs/core/server/api/prep-api-ts.ts | 7 ++++++- pkgs/core/utils/parcel.ts | 7 ++++++- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/app/srv/ws/sync/code/parts/init/typings.ts b/app/srv/ws/sync/code/parts/init/typings.ts index b7ab209d..1432d4b8 100644 --- a/app/srv/ws/sync/code/parts/init/typings.ts +++ b/app/srv/ws/sync/code/parts/init/typings.ts @@ -8,6 +8,7 @@ import { user } from "../../../entity/user"; import { conns } from "../../../entity/conn"; import { sendWS } from "../../../sync-handler"; import { SyncType } from "../../../type"; +import { platform } from "os"; export const initTypings = async ( root: string, id_site: string, @@ -42,7 +43,9 @@ export const initTypings = async ( spawn: Bun.spawn({ cmd: [ ...`${dir.path( - "node_modules/.bin/tsc" + platform() === "win32" + ? "node_modules/.bin/tsc.exe" + : "node_modules/.bin/tsc" )} --watch --moduleResolution node --emitDeclarationOnly --outFile ../typings.d.ts --declaration --noEmit false`.split( " " ), diff --git a/pkgs/core/build.ts b/pkgs/core/build.ts index 9cdc819d..eb720d5a 100644 --- a/pkgs/core/build.ts +++ b/pkgs/core/build.ts @@ -2,9 +2,10 @@ import { createId } from "@paralleldrive/cuid2"; import brotliPromise from "brotli-wasm"; import { Glob, spawn } from "bun"; import { dir } from "dir"; -import { build, context } from "esbuild"; +import { build } from "esbuild"; import { fdir } from "fdir"; import { statSync } from "fs"; +import { platform } from "os"; import { copyAsync, existsAsync, @@ -53,7 +54,11 @@ if (build_all) { const args = [ "node", - dir.path("node_modules/.bin/parcel"), + dir.path( + platform() === "win32" + ? "node_modules/.bin/parcel.exe" + : "node_modules/.bin/parcel" + ), "build", "./src/index.tsx", // "--no-optimize", diff --git a/pkgs/core/server/api/prep-api-ts.ts b/pkgs/core/server/api/prep-api-ts.ts index 7986ddfe..8896a77b 100644 --- a/pkgs/core/server/api/prep-api-ts.ts +++ b/pkgs/core/server/api/prep-api-ts.ts @@ -2,6 +2,7 @@ import { spawn } from "bun"; import { existsAsync, readAsync } from "fs-jetpack"; import { dir } from "../../utils/dir"; import { g } from "../../utils/global"; +import { platform } from "os"; export const prepareAPITypes = async () => { const out: string[] = []; @@ -36,7 +37,11 @@ export const ${name} = { const args = [ process.execPath, - dir.path("node_modules/.bin/tsc"), + dir.path( + platform() === "win32" + ? "node_modules/.bin/tsc.exe" + : "node_modules/.bin/tsc" + ), dir.path("app/srv/exports.ts"), "--declaration", "--emitDeclarationOnly", diff --git a/pkgs/core/utils/parcel.ts b/pkgs/core/utils/parcel.ts index c8fc7fe1..910404c6 100644 --- a/pkgs/core/utils/parcel.ts +++ b/pkgs/core/utils/parcel.ts @@ -2,6 +2,7 @@ import { spawn } from "bun"; import { dirAsync } from "fs-jetpack"; import { dir } from "./dir"; import { g } from "./global"; +import { platform } from "os"; const decoder = new TextDecoder(); export const parcelBuild = async () => { @@ -9,7 +10,11 @@ export const parcelBuild = async () => { const args = [ "node", - dir.path("node_modules/.bin/parcel"), + dir.path( + platform() === "win32" + ? "node_modules/.bin/parcel.exe" + : "node_modules/.bin/parcel" + ), g.mode === "dev" ? "watch" : "build", "./src/index.tsx", g.mode === "dev" ? "--no-hmr" : "--no-optimize",