Skip to content

Commit

Permalink
fix: 修复主进程编译函数
Browse files Browse the repository at this point in the history
  • Loading branch information
ch1ny committed Oct 26, 2023
1 parent c3a974e commit fbc02c2
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions src/creta/src/cli/utils/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,24 @@ export const buildPreload = async () =>
path.resolve(scriptsCwd, 'src', 'preload', 'tsconfig.json')
);

export const buildMain = async () =>
tscBuild(
(await fs.promises.readdir(path.resolve(scriptsCwd, 'src', 'main')))
.filter((file) => file.endsWith('.js') || file.endsWith('.ts'))
.map((file) => path.resolve(scriptsCwd, 'src', 'main', file)),
path.resolve(scriptsCwd, 'src', 'main', 'tsconfig.json')
);
export const buildMain = async () => {
const mainRootDir = path.resolve(scriptsCwd, 'src', 'main');
const nextDirList = [mainRootDir];
const filesToBuild: string[] = [];

let nextDir: string | undefined;
while ((nextDir = nextDirList.shift())) {
const files = await fs.promises.readdir(path.resolve(nextDir));
files.map(async (fileName) => {
const filePath = path.resolve(nextDir!, fileName);
const fsStatus = await fs.promises.stat(filePath);
if (fsStatus.isDirectory()) {
nextDirList.push(filePath);
} else if (filePath.endsWith('.js') || filePath.endsWith('.ts')) {
filesToBuild.push(filePath);
}
});
}

await tscBuild(filesToBuild, path.resolve(scriptsCwd, 'src', 'main', 'tsconfig.json'));
};

0 comments on commit fbc02c2

Please sign in to comment.