vscode_dwm-git-simpleuse/extension.js
2024-01-18 16:38:24 +01:00

98 lines
3 KiB
JavaScript

// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
const vscode = require("vscode");
const chp = require("child_process");
// This method is called when your extension is activated
// Your extension is activated the very first time the command is executed
/**
* @param {vscode.ExtensionContext} context
*/
function activate(context) {
// Use the console to output diagnostic information (console.log) and errors (console.error)
// This line of code will only be executed once when your extension is activated
console.log("yo!");
try {
process.chdir(vscode.workspace.workspaceFolders[0].uri.fsPath);
} catch (err) {
vscode.window.showErrorMessage(err);
}
chp.execFile("git", ["pull"], (err, stdout, stderr) => {
if (err) {
vscode.window.showErrorMessage("GITPULL : " + err.message);
return;
}
if (stderr) {
vscode.window.showErrorMessage("GITPULL : " + stderr);
return;
}
vscode.window.showInformationMessage("GITPULL : " + stdout);
});
// The command has been defined in the package.json file
// Now provide the implementation of the command with registerCommand
// The commandId parameter must match the command field in package.json
let disposable = vscode.commands.registerCommand(
"dwm-git-simpleuse.helloWorld",
function () {
chp.exec(
"git add . && git commit -am 'test77' && git pull && git push",
{ cwd: vscode.workspace.workspaceFolders[0].uri.fsPath },
(err, stdout, stderr) => {
if (err) {
vscode.window.showErrorMessage(err.message);
return;
}
if (stderr) {
vscode.window.showErrorMessage(stderr);
return;
}
vscode.window.showInformationMessage(stdout);
}
);
/* try {
process.chdir(vscode.workspace.workspaceFolders[0].uri.fsPath);
} catch (err) {
vscode.window.showErrorMessage(err);
} */
/* chp.execFile("git", ["add", "*"], (err, stdout, stderr) => {
if (err) {
vscode.window.showErrorMessage("GITADD : " + err.message);
return;
}
if (stderr) {
vscode.window.showErrorMessage("GITADD : " + stderr);
return;
}
vscode.window.showInformationMessage("GITADD : " + stdout);
});
chp.execFile(
"git",
["commit", "-m test7", "-a"],
(err, stdout, stderr) => {
if (err) {
vscode.window.showErrorMessage("GITCOM : " + err.message);
return;
}
if (stderr) {
vscode.window.showErrorMessage("GITCOM : " + stderr);
return;
}
vscode.window.showInformationMessage("GITCOM : " + stdout);
}
); */
}
);
context.subscriptions.push(disposable);
}
// This method is called when your extension is deactivated
function deactivate() {}
module.exports = {
activate,
deactivate,
};