forked from Mechanical-Advantage/EventDeployExtension
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathextension.js
46 lines (36 loc) · 1.19 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
const vscode = require("vscode")
const cp = require("child_process")
const branchPrefix = "event"
/**
* @param {vscode.ExtensionContext} context
*/
const windowOut = vscode.window.createOutputChannel('Event Deploy');
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.deploy", function () {
runCommand("git branch --show-current", branch => {
if (!branch.startsWith(branchPrefix)) {
windowOut.appendLine("Current branch '" + branch.trim() + '" is not a valid event branch.')
vscode.commands.executeCommand("wpilibcore.deployCode")
} 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
}