works
This commit is contained in:
parent
634d3b735b
commit
ae9d5711c3
3 changed files with 100 additions and 27 deletions
98
extension.js
98
extension.js
|
|
@ -1,6 +1,7 @@
|
|||
// 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 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
|
||||
|
|
@ -9,30 +10,89 @@ const vscode = require('vscode');
|
|||
* @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!");
|
||||
|
||||
// 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('Congratulations, your extension "dwm-git-simpleuse" is now active!');
|
||||
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 () {
|
||||
// The code you place here will be executed every time your command is executed
|
||||
// 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);
|
||||
}
|
||||
); */
|
||||
}
|
||||
);
|
||||
|
||||
// Display a message box to the user
|
||||
vscode.window.showInformationMessage('Hello World from DWM_git_simpleUse!');
|
||||
|
||||
|
||||
});
|
||||
|
||||
context.subscriptions.push(disposable);
|
||||
context.subscriptions.push(disposable);
|
||||
}
|
||||
|
||||
// This method is called when your extension is deactivated
|
||||
function deactivate() {}
|
||||
|
||||
module.exports = {
|
||||
activate,
|
||||
deactivate
|
||||
}
|
||||
activate,
|
||||
deactivate,
|
||||
};
|
||||
|
|
|
|||
8
package-lock.json
generated
8
package-lock.json
generated
|
|
@ -7,6 +7,9 @@
|
|||
"": {
|
||||
"name": "dwm-git-simpleuse",
|
||||
"version": "0.0.1",
|
||||
"dependencies": {
|
||||
"child_process": "^1.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/mocha": "^10.0.6",
|
||||
"@types/node": "18.x",
|
||||
|
|
@ -512,6 +515,11 @@
|
|||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/child_process": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/child_process/-/child_process-1.0.2.tgz",
|
||||
"integrity": "sha512-Wmza/JzL0SiWz7kl6MhIKT5ceIlnFPJX+lwUGj7Clhy5MMldsSoJR0+uvRzOS5Kv45Mq7t1PoE8TsOA9bzvb6g=="
|
||||
},
|
||||
"node_modules/chokidar": {
|
||||
"version": "3.5.3",
|
||||
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz",
|
||||
|
|
|
|||
21
package.json
21
package.json
|
|
@ -12,10 +12,12 @@
|
|||
"activationEvents": [],
|
||||
"main": "./extension.js",
|
||||
"contributes": {
|
||||
"commands": [{
|
||||
"command": "dwm-git-simpleuse.helloWorld",
|
||||
"title": "HelloWorld23"
|
||||
}]
|
||||
"commands": [
|
||||
{
|
||||
"command": "dwm-git-simpleuse.helloWorld",
|
||||
"title": "HelloWorld23"
|
||||
}
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
|
|
@ -23,12 +25,15 @@
|
|||
"test": "vscode-test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/vscode": "^1.85.0",
|
||||
"@types/mocha": "^10.0.6",
|
||||
"@types/node": "18.x",
|
||||
"eslint": "^8.56.0",
|
||||
"typescript": "^5.3.3",
|
||||
"@types/vscode": "^1.85.0",
|
||||
"@vscode/test-cli": "^0.0.4",
|
||||
"@vscode/test-electron": "^2.3.8"
|
||||
"@vscode/test-electron": "^2.3.8",
|
||||
"eslint": "^8.56.0",
|
||||
"typescript": "^5.3.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"child_process": "^1.0.2"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue