mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-26 13:19:34 +07:00
fix: scripts support win32 (#12613)
Co-authored-by: Innei <tukon479@gmail.com>
This commit is contained in:
21
scripts/copySpaBuild.mts
Normal file
21
scripts/copySpaBuild.mts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { cpSync, existsSync, mkdirSync } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
const root = path.resolve(import.meta.dirname, '..');
|
||||
const spaDir = path.resolve(root, 'public/spa');
|
||||
const distDirs = ['desktop', 'mobile'] as const;
|
||||
const copyDirs = ['assets', 'i18n', 'vendor'] as const;
|
||||
|
||||
mkdirSync(spaDir, { recursive: true });
|
||||
|
||||
for (const distDir of distDirs) {
|
||||
for (const dir of copyDirs) {
|
||||
const sourceDir = path.resolve(root, `dist/${distDir}/${dir}`);
|
||||
const targetDir = path.resolve(spaDir, dir);
|
||||
|
||||
if (!existsSync(sourceDir)) continue;
|
||||
|
||||
cpSync(sourceDir, targetDir, { recursive: true });
|
||||
console.log(`Copied dist/${distDir}/${dir} -> public/spa/${dir}`);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { type ChildProcess, spawn } from 'node:child_process';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
import net from 'node:net';
|
||||
import { resolve } from 'node:path';
|
||||
|
||||
const NEXT_HOST = 'localhost';
|
||||
|
||||
@@ -17,7 +17,9 @@ const resolveNextPort = (): number => {
|
||||
const match = devNext.match(/(?:--port|-p)\s+(\d+)/);
|
||||
if (match) return Number(match[1]);
|
||||
}
|
||||
} catch { /* fallback */ }
|
||||
} catch {
|
||||
/* fallback */
|
||||
}
|
||||
return 3010;
|
||||
};
|
||||
|
||||
@@ -36,6 +38,7 @@ const runNpmScript = (scriptName: string) =>
|
||||
spawn(npmCommand, ['run', scriptName], {
|
||||
env: process.env,
|
||||
stdio: 'inherit',
|
||||
shell: process.platform === 'win32',
|
||||
});
|
||||
|
||||
const wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
|
||||
Reference in New Issue
Block a user