Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongfq committed Apr 17, 2024
1 parent 809f8c1 commit 708102e
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions src/contexts/workspace-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,26 +231,27 @@ export const useWorkspace = create<WorkspaceStore>((set, get) => ({

buildProject: () => {
const workspace = get();
if (!buildDir && workspace.path) {
buildDir = dialog.showOpenDialogSync({
properties: ["openDirectory", "createDirectory"],
})?.[0];
if (buildDir) {
for (const editor of workspace.editors) {
editor.dispatch?.("save");
}
try {
for (const path of workspace.allFiles) {
const buildpath = buildDir + "/" + Path.relative(workspace.workdir, path);
console.log("build:", buildpath);
const treeModel = b3util.createBuildData(path);
fs.mkdirSync(Path.dirname(buildpath), { recursive: true });
fs.writeFileSync(buildpath, JSON.stringify(treeModel, null, 2));
}
message.success(i18n.t("buildCompleted"));
} catch (error) {
console.error(error);
if (workspace.path)
if (!buildDir) {
buildDir = dialog.showOpenDialogSync({
properties: ["openDirectory", "createDirectory"],
})?.[0];
}
if (buildDir) {
for (const editor of workspace.editors) {
editor.dispatch?.("save");
}
try {
for (const path of workspace.allFiles) {
const buildpath = buildDir + "/" + Path.relative(workspace.workdir, path);
console.log("build:", buildpath);
const treeModel = b3util.createBuildData(path);
fs.mkdirSync(Path.dirname(buildpath), { recursive: true });
fs.writeFileSync(buildpath, JSON.stringify(treeModel, null, 2));
}
message.success(i18n.t("buildCompleted"));
} catch (error) {
console.error(error);
}
}
},
Expand Down

0 comments on commit 708102e

Please sign in to comment.