Refactor vscode init to use async

Hopefully is a bit easier to read.
This commit is contained in:
Asher 2020-11-10 18:20:44 -06:00
parent 71850e312b
commit 4574593664
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A

View File

@ -22,18 +22,14 @@ router.get("/", async (req, res) => {
const [content, options] = await Promise.all([
await fs.readFile(path.join(rootPath, "src/browser/pages/vscode.html"), "utf8"),
vscode
.initialize(
{
args: req.args,
remoteAuthority: req.headers.host || "",
},
req.query,
)
.catch((error) => {
(async () => {
try {
return await vscode.initialize({ args: req.args, remoteAuthority: req.headers.host || "" }, req.query)
} catch (error) {
const devMessage = commit === "development" ? "It might not have finished compiling." : ""
throw new Error(`VS Code failed to load. ${devMessage} ${error.message}`)
}),
}
})(),
])
options.productConfiguration.codeServerVersion = version