-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathextension.js
50 lines (44 loc) · 1.22 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
43
44
45
46
47
48
49
50
const vscode = require("vscode");
const cp = require("child_process");
const branchPrefix = "event";
/**
* @param {vscode.ExtensionContext} context
*/
function activate(context) {
function runCommand(command, callback) {
cp.exec(
command,
{ cwd: vscode.workspace.workspaceFolders[0].uri.fsPath },
(err, stdout, stderr) => {
callback(stdout);
}
);
}
context.subscriptions.push(
vscode.commands.registerCommand("event-deploy-wpilib.deploy", function () {
runCommand("git branch --show-current", (branch) => {
if (!branch.startsWith(branchPrefix)) {
vscode.window.showErrorMessage(
'Current branch "' +
branch.trim() +
'" is not a valid event branch.'
);
} else {
var commitMessage = 'Update at "' + new Date().toLocaleString() + '"';
runCommand("git add -A", () => {
runCommand("git commit -m '" + commitMessage + "'", () => {
vscode.commands.executeCommand("wpilibcore.deployCode");
});
});
}
});
})
);
}
// @ts-ignore
exports.activate = activate;
function deactivate() {}
module.exports = {
activate,
deactivate,
};