-
Notifications
You must be signed in to change notification settings - Fork 0
/
extension.js
42 lines (31 loc) · 1.2 KB
/
extension.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const { boil, BOILER_DIRECTORY, getTemplates, readTemplate } = require('../bojler');
const vscode = require('vscode');
exports.activate = (context) => {
console.log('Bojler extension is active.');
var disposable = vscode.commands.registerCommand('extension.bojler', async (commandContext) => {
if (typeof commandContext === 'undefined') {
await vscode.window.showErrorMessage('commandContext is undefined');
return;
}
const templates = await getTemplates();
if (templates.length === 0) {
await vscode.window.showErrorMessage(`No templates in ${BOILER_DIRECTORY}`);
return;
}
const templateFilename = await vscode.window.showQuickPick(templates, {
canPickMany: false,
title: 'Choose template',
});
if (typeof templateFilename === 'undefined') {
return;
}
const template = readTemplate(templateFilename);
const parameters = {};
for (const [name, prompt] of Object.entries(template.parameters)) {
parameters[name] = await vscode.window.showInputBox({ prompt });
}
await boil(templateFilename, commandContext.path, parameters);
});
context.subscriptions.push(disposable);
};
exports.deactivate = () => {};