Skip to content

Commit d9ee244

Browse files
committed
fix: dev when sprase-checkout
1 parent 74a8de3 commit d9ee244

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

lib/mongo/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { isProd } from '../constants';
22
import { addLog } from '../utils/log';
3-
import type { Model, Schema, Mongoose as MongooseType } from 'mongoose';
3+
import type { Model, Schema } from 'mongoose';
44
import { Mongoose } from 'mongoose';
55

66
export const MONGO_URL = process.env.MONGODB_URI ?? '';

modules/tool/init.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { addLog } from '@/utils/log';
99
import { basePath, toolsDir, tempDir, tempToolsDir, UploadToolsS3Path } from './constants';
1010
import { privateS3Server } from '@/s3';
1111
import { LoadToolsByFilename } from './utils';
12+
import { stat } from 'fs/promises';
1213

1314
const filterToolList = ['.DS_Store', '.git', '.github', 'node_modules', 'dist', 'scripts'];
1415

@@ -46,6 +47,12 @@ export async function initTools() {
4647
// 3. read dev tools, if in dev mode
4748
if (!isProd && process.env.DISABLE_DEV_TOOLS !== 'true') {
4849
const dir = join(basePath, 'modules', 'tool', 'packages');
50+
// skip if dir not exist
51+
try {
52+
await stat(dir);
53+
} catch (e) {
54+
return toolMap;
55+
}
4956
const dirs = (await readdir(dir)).filter((filename) => !filterToolList.includes(filename));
5057
const devTools = (
5158
await Promise.all(

runtime/dev/index.ts

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,15 @@ import { basePath } from '@tool/constants';
88
async function copyDevIcons() {
99
if (isProd) return;
1010

11-
const toolsDir = path.join(basePath, 'modules', 'tool', 'packages');
12-
const publicImgsToolsDir = path.join(basePath, 'public', 'imgs', 'tools');
1311
const modelsDir = path.join(basePath, 'modules', 'model', 'provider');
1412
const publicImgsModelsDir = path.join(basePath, 'public', 'imgs', 'models');
1513

1614
// Copy tool and model icons in parallel
17-
await Promise.all([
18-
copyIcons({
19-
sourceDir: toolsDir,
20-
targetDir: publicImgsToolsDir,
21-
logPrefix: 'Copied dev tool icon'
22-
}),
23-
copyIcons({
24-
sourceDir: modelsDir,
25-
targetDir: publicImgsModelsDir,
26-
logPrefix: 'Copied dev model icon'
27-
})
28-
]);
15+
await copyIcons({
16+
sourceDir: modelsDir,
17+
targetDir: publicImgsModelsDir,
18+
logPrefix: 'Copied dev model icon'
19+
});
2920
}
3021

3122
async function checkToolDir() {
@@ -54,7 +45,7 @@ async function checkToolDir() {
5445
}
5546

5647
await copyDevIcons();
57-
await checkToolDir();
48+
// await checkToolDir();
5849

5950
const server = new DevServer();
6051
await server.start();

0 commit comments

Comments
 (0)