Skip to content

Commit dce3769

Browse files
committed
compile with progress
1 parent cae07da commit dce3769

File tree

1 file changed

+28
-19
lines changed

1 file changed

+28
-19
lines changed

src/commands/compile.ts

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -68,25 +68,34 @@ async function loadChanges(files: CurrentFile[]): Promise<any> {
6868
async function compile(docs: CurrentFile[], flags?: string): Promise<any> {
6969
flags = flags || config("compileFlags");
7070
const api = new AtelierAPI(docs[0].uri);
71-
return api
72-
.actionCompile(docs.map(el => el.name), flags)
73-
.then(data => {
74-
const info = docs.length > 1 ? "" : `${docs[0].name}: `;
75-
if (data.status && data.status.errors && data.status.errors.length) {
76-
throw new Error(`${info}Compile error`);
77-
} else if (!config("suppressCompileMessages")) {
78-
vscode.window.showInformationMessage(`${info}Compilation succeeded`, "Hide");
79-
}
80-
return docs;
81-
})
82-
.catch((error: Error) => {
83-
outputChannel.appendLine(error.message);
84-
outputChannel.show(true);
85-
vscode.window.showErrorMessage(error.message, "Show details").then(data => {
86-
outputChannel.show(true);
87-
});
88-
return [];
89-
})
71+
return vscode.window
72+
.withProgress(
73+
{
74+
cancellable: false,
75+
location: vscode.ProgressLocation.Notification,
76+
title: `Compiling: ${docs.length === 1 ? docs.map(el => el.name).join(", ") : docs.length + " files"}`,
77+
},
78+
() =>
79+
api
80+
.actionCompile(docs.map(el => el.name), flags)
81+
.then(data => {
82+
const info = docs.length > 1 ? "" : `${docs[0].name}: `;
83+
if (data.status && data.status.errors && data.status.errors.length) {
84+
throw new Error(`${info}Compile error`);
85+
} else if (!config("suppressCompileMessages")) {
86+
vscode.window.showInformationMessage(`${info}Compilation succeeded`, "Hide");
87+
}
88+
return docs;
89+
})
90+
.catch((error: Error) => {
91+
outputChannel.appendLine(error.message);
92+
outputChannel.show(true);
93+
vscode.window.showErrorMessage(error.message, "Show details").then(data => {
94+
outputChannel.show(true);
95+
});
96+
return [];
97+
})
98+
)
9099
.then(loadChanges);
91100
}
92101

0 commit comments

Comments
 (0)