-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathextension.js
More file actions
45 lines (35 loc) · 1.01 KB
/
extension.js
File metadata and controls
45 lines (35 loc) · 1.01 KB
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
43
44
45
const vscode = require('vscode');
const actions = require('./actions');
const { setConfigOptions } = require('./modules/config-service');
const { showInfoMessage } = require('./modules/ui-services/messageService');
function activate(context) {
const formatDocument = () =>
vscode.commands.executeCommand("editor.action.formatDocument")
actions
.forEach(function (action) {
const disposable = vscode.commands.registerCommand(
action.commandId,
function () {
setConfigOptions(vscode.workspace.getConfiguration('js-codeformer'));
try {
const codeAction = require(action.path);
codeAction[action.name]()
.then(function (message) {
if(typeof message === 'string' && message.trim() !== '') {
showInfoMessage(message.trim());
}
})
.then(formatDocument);
} catch (error) {
console.log(error)
}
}
);
context.subscriptions.push(disposable);
});
}
function deactivate() { }
module.exports = {
activate,
deactivate
}