├── .gitignore
├── .vscode
└── launch.json
├── .vscodeignore
├── README.md
├── extension.js
├── images
└── logo_128.png
├── jsconfig.json
├── package.json
├── test
├── extension.test.js
└── index.js
├── typings
├── node.d.ts
└── vscode-typings.d.ts
└── vsc-extension-quickstart.md
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | // A launch configuration that launches the extension inside a new window
2 | {
3 | "version": "0.1.0",
4 | "configurations": [
5 | {
6 | "name": "Launch Extension",
7 | "type": "extensionHost",
8 | "request": "launch",
9 | "runtimeExecutable": "${execPath}",
10 | "args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
11 | "stopOnEntry": false,
12 | "env": {
13 | "ENV": "development"
14 | }
15 | },
16 | {
17 | "name": "Launch Tests",
18 | "type": "extensionHost",
19 | "request": "launch",
20 | "runtimeExecutable": "${execPath}",
21 | "args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/test" ],
22 | "stopOnEntry": false
23 | }
24 | ]
25 | }
--------------------------------------------------------------------------------
/.vscodeignore:
--------------------------------------------------------------------------------
1 | .vscode/**
2 | typings/**
3 | test/**
4 | .gitignore
5 | jsconfig.json
6 | vsc-extension-quickstart.md
7 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # git-easy README
2 |
3 | Git Easy makes is really easy to use Git with your project. This is inspired by the git plugin of Sublime Text.
4 |
5 | ## Features
6 |
7 | It currently supports these commands -
8 |
9 | - Git Easy: Init
10 | - Git Easy: Add Origin
11 | - Git Easy: Add Remote
12 | - Git Easy: Add File/Directory
13 | - Git Easy: Add All Modified
14 | - Git Easy: Commit
15 | - Git Easy: Pull Current Branch from Origin
16 | - Git Easy: Push Current Branch to Origin
17 | - Git Easy: Push Current Branch (to any remote)
18 | - Git Easy: Status
19 | - Git Easy: Create New Branch
20 | - Git Easy: Change/Checkout Existing Branch
21 | - Git Easy: Log All
22 | - Git Easy: Log Current File
23 |
24 | ## Requirements
25 |
26 | Currently it has just one requirement - `simple-git`, that will get installed along with the extension.
27 |
28 | ## Release Notes
29 |
30 | ### 1.8.0
31 |
32 | Fixed bug with log command
33 |
34 | ### 1.7.0
35 |
36 | Added command to add remote.
37 |
38 | ### 0.0.6
39 |
40 | Added Git Log. Clicking a log opens the details of that commit.
41 |
42 | ### 0.0.5
43 |
44 | Minor bugfixes and updated logo
45 |
46 | ### 0.0.1
47 |
48 | Initial release of Git Easy.
--------------------------------------------------------------------------------
/extension.js:
--------------------------------------------------------------------------------
1 | // The module 'vscode' contains the VS Code extensibility API
2 | // Import the module and reference it with the alias vscode in your code below
3 | var vscode = require('vscode');
4 | var projectRoot = vscode.workspace.rootPath;
5 | // var projectRoot = "/home/bibhas/Rivendell/vscode/git-easy/";
6 | var simpleGit = require('simple-git')((projectRoot) ? projectRoot : '.');
7 | var childProcess = require('child_process');
8 | var fs = require('fs');
9 | var os = require('os');
10 |
11 | // this method is called when your extension is activated
12 | // your extension is activated the very first time the command is executed
13 | function activate(context) {
14 | var outputChannel = vscode.window.createOutputChannel("GitEasy");
15 |
16 | var disposableInit = vscode.commands.registerCommand('giteasy.doInit', function () {
17 | if (projectRoot === undefined) {
18 | vscode.window.showErrorMessage("No directory open. Please open a directory first.")
19 | } else {
20 | simpleGit.init(function () {
21 | vscode.window.showInformationMessage("Initiated git repository at " + projectRoot);
22 | });
23 | }
24 | });
25 |
26 | var disposableLogAll = vscode.commands.registerCommand('giteasy.doLogAll', function () {
27 | simpleGit.log({}, function (error, result) {
28 | if (error) {
29 | showOutput(error);
30 | return;
31 | }
32 | var last100 = result.all.slice(0, 100);
33 | var logs = fillCommits(last100);
34 | vscode.window.showQuickPick(logs).then(function (result) {
35 | if (result == null) {
36 | return;
37 | }
38 | simpleGit.show([result.description, ], function (error, result) {
39 | if (error) throw error;
40 | showSidebarDiff(result);
41 | });
42 | })
43 | })
44 | });
45 |
46 | var disposableLogCurrentFile = vscode.commands.registerCommand('giteasy.doLogCurrentFile', function () {
47 | simpleGit.log({'file': vscode.window.activeTextEditor.document.fileName}, function (error, result) {
48 | if (error) {
49 | showOutput(error);
50 | return;
51 | }
52 | var logs = fillCommits(result.all);
53 | vscode.window.showQuickPick(logs).then(function (result) {
54 | if (result == null) {
55 | return;
56 | }
57 | simpleGit.show([result.description, ], function (error, result) {
58 | if (error) throw error;
59 | showSidebarDiff(result);
60 | });
61 | })
62 | })
63 | });
64 |
65 | var disposableCheckoutCurrentFile = vscode.commands.registerCommand('giteasy.doCheckoutCurrentFile', function () {
66 | simpleGit.checkout(vscode.window.activeTextEditor.document.fileName, function (error, result) {
67 | if (error) {
68 | showOutput(error);
69 | return;
70 | }
71 | })
72 | })
73 |
74 | var fillCommits = function(listOfCommits) {
75 | var logs = [];
76 | listOfCommits.forEach(function(element) {
77 | if (!element.hasOwnProperty("hash")) {
78 | return;
79 | }
80 | logs.push({
81 | 'label': element.message,
82 | 'detail': timeSince(new Date(element.date)) + " by " + (element.author_name || element.author_email) + " | " + element.date,
83 | 'description': element.hash.substring(0, 7)
84 | })
85 | }, this);
86 | return logs;
87 |
88 | }
89 |
90 | var disposableOriginCurrentPull = vscode.commands.registerCommand('giteasy.doOriginCurrentPull', function () {
91 | simpleGit.branch(function(error, branchSummary) {
92 | if (error) {
93 | showOutput(error);
94 | return;
95 | } else if (branchSummary.all.length == 0) {
96 | vscode.window.showErrorMessage("No branches found. Git add files and commit maybe?")
97 | } else {
98 | console.log(branchSummary);
99 | simpleGit.pull("origin", branchSummary.current, function(err, update) {
100 | if(update && update.summary.changes) {
101 | showOutput(update.summary.changes);
102 | } else if (err) {
103 | showOutput(err);
104 | }
105 | });
106 | }
107 | })
108 | });
109 |
110 | var disposableOriginCurrentPush = vscode.commands.registerCommand('giteasy.doOriginCurrentPush', function () {
111 | simpleGit.branch(function(error, branchSummary) {
112 | if (error) {
113 | showOutput(error);
114 | return;
115 | }
116 | simpleGit.outputHandler(function (command, stdout, stderr) {
117 | stdout.on('data', function(buffer) {
118 | outputChannel.clear();
119 | appendOutput(buffer.toString('utf8'));
120 | });
121 | stderr.on('data', function(buffer) {
122 | outputChannel.clear();
123 | appendOutput(buffer.toString('utf8'));
124 | });
125 | }).push("origin", branchSummary.current, function () {});
126 | simpleGit.outputHandler(function (command, stdout, stderr) {
127 | // do nothinggg
128 | })
129 | })
130 | });
131 |
132 | var disposableRemoteCurrentPush = vscode.commands.registerCommand('giteasy.doRemoteCurrentPush', function () {
133 | simpleGit.getRemotes(function (error, remotes) {
134 | if (error) {
135 | showOutput(error);
136 | return;
137 | }
138 | var arr_remotes = [];
139 | remotes.forEach(function(element) {
140 | arr_remotes.push(element.name);
141 | }, this);
142 | vscode.window.showQuickPick(arr_remotes).then(function (remote) {
143 | simpleGit.branch(function(error, branchSummary) {
144 | if (error) {
145 | showOutput(error);
146 | return;
147 | }
148 | simpleGit.outputHandler(function (command, stdout, stderr) {
149 | stdout.on('data', function(buffer) {
150 | outputChannel.clear();
151 | appendOutput(buffer.toString('utf8'));
152 | });
153 | stderr.on('data', function(buffer) {
154 | outputChannel.clear();
155 | appendOutput(buffer.toString('utf8'));
156 | });
157 | }).push(remote, branchSummary.current, function () {});
158 | simpleGit.outputHandler(function (command, stdout, stderr) {
159 | // do nothinggg
160 | });
161 | });
162 | });
163 | });
164 | });
165 |
166 | var disposableAddRemote = vscode.commands.registerCommand('giteasy.doAddRemote', function () {
167 | vscode.window.showInputBox({
168 | 'placeHolder': "Enter remote name"
169 | }).then(function (remote) {
170 | if (!remote) {
171 | vscode.window.showErrorMessage("You must enter a name for the remote");
172 | return;
173 | }
174 | vscode.window.showInputBox({
175 | 'placeHolder': "Enter remote url"
176 | }).then(function (url) {
177 | if (!url) {
178 | vscode.window.showErrorMessage("You must enter a url for the remote");
179 | return;
180 | }
181 | simpleGit.addRemote(remote, url, function(err, result) {
182 | if (err) {
183 | showOutput(err);
184 | return;
185 | }
186 | })
187 | })
188 | });
189 | });
190 |
191 | var disposableAddOrigin = vscode.commands.registerCommand('giteasy.doAddOrigin', function () {
192 | vscode.window.showInputBox({
193 | 'placeHolder': "Enter origin URL"
194 | }).then(function (message) {
195 | simpleGit.addRemote("origin", message, function(err, result) {
196 | if (err) {
197 | showOutput(err);
198 | return;
199 | }
200 | })
201 | });
202 | });
203 |
204 | var disposableChangeBranch = vscode.commands.registerCommand('giteasy.doChangeBranch', function () {
205 | simpleGit.branch(function(error, branchSummary) {
206 | if (error) {
207 | showOutput(error);
208 | return;
209 | }
210 | console.log(branchSummary);
211 | var branches = [];
212 | branchSummary.all.forEach(function(element) {
213 | if (!element.startsWith("remotes/")) {
214 | if (element == branchSummary.current) {
215 | branches.push("(current) " + element);
216 | } else {
217 | branches.push(element);
218 | }
219 | }
220 | }, this);
221 | vscode.window.showQuickPick(branches).then(function(result) {
222 | if (result == null) {
223 | return;
224 | }
225 | if (!result.startsWith("(current)")) {
226 | simpleGit.checkout(result, function (error, result) {
227 | if (error) {
228 | showOutput(error);
229 | }
230 | })
231 | }
232 | })
233 | });
234 | });
235 |
236 | var disposableCreateBranch = vscode.commands.registerCommand('giteasy.doCreateBranch', function () {
237 | vscode.window.showInputBox({
238 | 'placeHolder': "Enter new branch name"
239 | }).then(function (branchName) {
240 | simpleGit.checkoutLocalBranch(branchName, function (error, result) {
241 | if (error) {
242 | showOutput(error);
243 | }
244 | })
245 | });
246 | });
247 |
248 | var disposableCommit = vscode.commands.registerCommand('giteasy.doCommit', function () {
249 | vscode.window.showInputBox({
250 | 'placeHolder': "Enter your commit message"
251 | }).then(function (message) {
252 | if (message === undefined) {
253 | return;
254 | } else if (message === "") {
255 | vscode.window.showInformationMessage("You must enter a commit message!");
256 | } else {
257 | simpleGit.commit(message, function (error, result) {
258 | if (error) {
259 | showOutput(error);
260 | return;
261 | } else {
262 | console.log(result);
263 | var msg = "Committed to branch " + result.branch + " (" + result.commit + ")\n" +
264 | result.summary.changes + " change(s), " +
265 | result.summary.insertions + " addition(s), " +
266 | result.summary.deletions + " deletion(s).";
267 | showOutput(msg);
268 | }
269 | })
270 | }
271 | })
272 | });
273 |
274 | var disposableAdd = vscode.commands.registerCommand('giteasy.doAdd', function () {
275 | var fileList = [];
276 | simpleGit.status(function(error, status) {
277 | if (error) {
278 | showOutput(error);
279 | return;
280 | }
281 | fileList.push({
282 | 'label': "Add All Modified",
283 | 'description': "AddAllModified"
284 | })
285 | fileList.push({
286 | 'label': "Add All Modified + Untracked",
287 | 'description': "AddAllModifiedUntracked"
288 | })
289 | fileList = fillFileList(status, fileList, true)
290 |
291 | var qp = vscode.window.showQuickPick(fileList);
292 | qp.then(function (result) {
293 | if (result == null) {
294 | return;
295 | }
296 | if (result.description == "AddAllModified") {
297 | simpleGit.status(function(error, status) {
298 | status.modified.forEach(function(element) {
299 | simpleGit.add(element);
300 | }, this);
301 | });
302 | } else if (result.description == "AddAllModifiedUntracked") {
303 | simpleGit.status(function(error, status) {
304 | status.modified.forEach(function(element) {
305 | simpleGit.add(element);
306 | }, this);
307 | status.not_added.forEach(function(element) {
308 | simpleGit.add(element);
309 | }, this);
310 | });
311 | } else {
312 | simpleGit.add(result.label, function (result) {
313 | console.log(result);
314 | })
315 | }
316 | })
317 | });
318 | });
319 |
320 | var disposableAddAll = vscode.commands.registerCommand('giteasy.doAddAll', function () {
321 | simpleGit.status(function(error, status) {
322 | if (error) {
323 | showOutput(error);
324 | return;
325 | }
326 | status.modified.forEach(function(element) {
327 | simpleGit.add(element);
328 | }, this);
329 | });
330 | });
331 |
332 | var disposableAddCurrentFile = vscode.commands.registerCommand('giteasy.doAddCurrentFile', function () {
333 | simpleGit.add(vscode.window.activeTextEditor.document.fileName);
334 | });
335 |
336 | var disposableUnstageCurrentFile = vscode.commands.registerCommand('giteasy.doUnstageCurrentFile', function () {
337 | simpleGit.reset(["--", vscode.window.activeTextEditor.document.fileName], function (error) {
338 | if (error) {
339 | showOutput(error);
340 | return;
341 | }
342 | });
343 | });
344 |
345 | var disposableStatus = vscode.commands.registerCommand('giteasy.doStatus', function () {
346 | var fileList = [];
347 | simpleGit.status(function(error, status) {
348 | console.log(status);
349 | if (error) {
350 | showOutput(error);
351 | return;
352 | }
353 | fileList = fillFileList(status, fileList, false);
354 |
355 | var qp = vscode.window.showQuickPick(fileList);
356 | qp.then(function (result) {
357 | if (result == null) {
358 | return;
359 | }
360 | if (["Untracked", "New"].indexOf(result.description) >= 0) {
361 | return;
362 | } else {
363 | simpleGit.diff([result.label, ], function (error, result) {
364 | if (error) throw error;
365 |
366 | var diffFile = os.tmpdir() + "/.git-easy.diff";
367 |
368 | fs.writeFile(diffFile, result, (err) => {
369 | if (err) throw err;
370 | vscode.workspace.openTextDocument(diffFile)
371 | .then(function (file) {
372 | vscode.window.showTextDocument(file, vscode.ViewColumn.Two, false);
373 | });
374 | });
375 | });
376 | }
377 | })
378 | });
379 | });
380 |
381 | context.subscriptions.push(disposableInit);
382 | context.subscriptions.push(disposableOriginCurrentPull);
383 | context.subscriptions.push(disposableOriginCurrentPush);
384 | context.subscriptions.push(disposableRemoteCurrentPush);
385 | context.subscriptions.push(disposableAdd);
386 | context.subscriptions.push(disposableAddAll);
387 | context.subscriptions.push(disposableAddCurrentFile);
388 | context.subscriptions.push(disposableUnstageCurrentFile);
389 | context.subscriptions.push(disposableStatus);
390 | context.subscriptions.push(disposableCommit);
391 | context.subscriptions.push(disposableAddOrigin);
392 | context.subscriptions.push(disposableAddRemote);
393 | context.subscriptions.push(disposableChangeBranch);
394 | context.subscriptions.push(disposableCreateBranch);
395 | context.subscriptions.push(disposableLogCurrentFile);
396 | context.subscriptions.push(disposableCheckoutCurrentFile);
397 |
398 | function fillFileList(status, fileList, is_gitadd=false) {
399 | console.log(status);
400 | status.modified.forEach(function(element) {
401 | var item = {
402 | 'label': element,
403 | 'description': "Modified"
404 | };
405 | fileList.push(item);
406 | }, this);
407 | status.not_added.forEach(function(element) {
408 | var item = {
409 | 'label': element,
410 | 'description': "Untracked"
411 | };
412 | fileList.push(item)
413 | }, this);
414 |
415 | if (!is_gitadd) {
416 | status.created.forEach(function(element) {
417 | var item = {
418 | 'label': element,
419 | 'description': "New"
420 | };
421 | fileList.push(item)
422 | }, this);
423 | }
424 | return fileList;
425 | }
426 | function showSidebarDiff(text) {
427 | fs.writeFile('/tmp/.git-easy.diff', text, (err) => {
428 | if (err) throw err;
429 | vscode.workspace.openTextDocument('/tmp/.git-easy.diff')
430 | .then(function (file) {
431 | vscode.window.showTextDocument(file, vscode.ViewColumn.Two, false);
432 | });
433 | });
434 | }
435 | function showOutput(text) {
436 | outputChannel.clear();
437 | outputChannel.append(text);
438 | outputChannel.show(vscode.ViewColumn.Three);
439 | }
440 | function appendOutput(text) {
441 | outputChannel.show(vscode.ViewColumn.Three);
442 | outputChannel.appendLine(text);
443 | }
444 | function timeSince(date) {
445 | var seconds = Math.floor((new Date() - date) / 1000);
446 | var interval = Math.floor(seconds / 31536000);
447 | if (interval > 1) {
448 | return interval + " years";
449 | }
450 | interval = Math.floor(seconds / 2592000);
451 | if (interval > 1) {
452 | return interval + " months";
453 | }
454 | interval = Math.floor(seconds / 86400);
455 | if (interval > 1) {
456 | return interval + " days";
457 | }
458 | interval = Math.floor(seconds / 3600);
459 | if (interval > 1) {
460 | return interval + " hours";
461 | }
462 | interval = Math.floor(seconds / 60);
463 | if (interval > 1) {
464 | return interval + " minutes";
465 | }
466 | return Math.floor(seconds) + " seconds";
467 | }
468 | }
469 | exports.activate = activate;
470 |
471 | // this method is called when your extension is deactivated
472 | function deactivate() {
473 | }
474 | exports.deactivate = deactivate;
475 |
--------------------------------------------------------------------------------
/images/logo_128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iambibhas/vscode-git-easy/0fbac7c541e5e2f7fd41af92e60b580bacee506b/images/logo_128.png
--------------------------------------------------------------------------------
/jsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "ES5",
5 | "noLib": true
6 | },
7 | "exclude": [
8 | "node_modules"
9 | ]
10 | }
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "git-easy",
3 | "displayName": "Git Easy",
4 | "description": "Making git easy and convenient",
5 | "version": "1.11.0",
6 | "publisher": "bibhasdn",
7 | "icon": "images/logo_128.png",
8 | "repository": {
9 | "type": "git",
10 | "url": "https://github.com/iambibhas/vscode-git-easy"
11 | },
12 | "bugs": {
13 | "url": "https://github.com/iambibhas/vscode-git-easy/issues",
14 | "email": "me@bibhas.in"
15 | },
16 | "engines": {
17 | "vscode": "^1.0.0"
18 | },
19 | "dependencies": {
20 | "simple-git": "*"
21 | },
22 | "categories": [
23 | "Other"
24 | ],
25 | "keywords": [
26 | "git",
27 | "github",
28 | "sublime",
29 | "sublimetext",
30 | "vcs"
31 | ],
32 | "activationEvents": [
33 | "onCommand:giteasy.countChars",
34 | "onCommand:giteasy.doOriginCurrentPull",
35 | "onCommand:giteasy.doOriginCurrentPush",
36 | "onCommand:giteasy.doRemoteCurrentPush",
37 | "onCommand:giteasy.doStatus",
38 | "onCommand:giteasy.doAdd",
39 | "onCommand:giteasy.doAddAll",
40 | "onCommand:giteasy.doAddCurrentFile",
41 | "onCommand:giteasy.doUnstageCurrentFile",
42 | "onCommand:giteasy.doCommit",
43 | "onCommand:giteasy.doInit",
44 | "onCommand:giteasy.doAddOrigin",
45 | "onCommand:giteasy.doAddRemote",
46 | "onCommand:giteasy.doChangeBranch",
47 | "onCommand:giteasy.doCreateBranch",
48 | "onCommand:giteasy.doLogAll",
49 | "onCommand:giteasy.doLogCurrentFile",
50 | "onCommand:giteasy.doCheckoutCurrentFile"
51 | ],
52 | "main": "./extension",
53 | "contributes": {
54 | "commands": [{
55 | "command": "giteasy.doInit",
56 | "title": "Git Easy: Init"
57 | }, {
58 | "command": "giteasy.doOriginCurrentPull",
59 | "title": "Git Easy: Pull Current Branch from Origin"
60 | }, {
61 | "command": "giteasy.doOriginCurrentPush",
62 | "title": "Git Easy: Push Current Branch to Origin"
63 | }, {
64 | "command": "giteasy.doRemoteCurrentPush",
65 | "title": "Git Easy: Push Current Branch"
66 | }, {
67 | "command": "giteasy.doAdd",
68 | "title": "Git Easy: Add File/Directory"
69 | }, {
70 | "command": "giteasy.doAddAll",
71 | "title": "Git Easy: Add All Modified"
72 | }, {
73 | "command": "giteasy.doAddCurrentFile",
74 | "title": "Git Easy: Add Current File"
75 | }, {
76 | "command": "giteasy.doUnstageCurrentFile",
77 | "title": "Git Easy: Unstage Current File"
78 | }, {
79 | "command": "giteasy.doStatus",
80 | "title": "Git Easy: Status"
81 | }, {
82 | "command": "giteasy.doCommit",
83 | "title": "Git Easy: Commit"
84 | }, {
85 | "command": "giteasy.doAddOrigin",
86 | "title": "Git Easy: Add Origin"
87 | }, {
88 | "command": "giteasy.doAddRemote",
89 | "title": "Git Easy: Add Remote"
90 | }, {
91 | "command": "giteasy.doChangeBranch",
92 | "title": "Git Easy: Change/Checkout Existing Branch"
93 | }, {
94 | "command": "giteasy.doCreateBranch",
95 | "title": "Git Easy: Create New Branch"
96 | }, {
97 | "command": "giteasy.doLogAll",
98 | "title": "Git Easy: Log All"
99 | }, {
100 | "command": "giteasy.doLogCurrentFile",
101 | "title": "Git Easy: Log Current File"
102 | }, {
103 | "command": "giteasy.doCheckoutCurrentFile",
104 | "title": "Git Easy: Checkout Current File"
105 | }]
106 | },
107 | "scripts": {
108 | "postinstall": "node ./node_modules/vscode/bin/install"
109 | },
110 | "devDependencies": {
111 | "vscode": "^0.11.0",
112 | "simple-git": "*"
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/test/extension.test.js:
--------------------------------------------------------------------------------
1 | /* global suite, test */
2 |
3 | //
4 | // Note: This example test is leveraging the Mocha test framework.
5 | // Please refer to their documentation on https://mochajs.org/ for help.
6 | //
7 |
8 | // The module 'assert' provides assertion methods from node
9 | var assert = require('assert');
10 |
11 | // You can import and use all API from the 'vscode' module
12 | // as well as import your extension to test it
13 | var vscode = require('vscode');
14 | var myExtension = require('../extension');
15 |
16 | // Defines a Mocha test suite to group tests of similar kind together
17 | suite("Extension Tests", function() {
18 |
19 | // Defines a Mocha unit test
20 | test("Something 1", function() {
21 | assert.equal(-1, [1, 2, 3].indexOf(5));
22 | assert.equal(-1, [1, 2, 3].indexOf(0));
23 | });
24 | });
--------------------------------------------------------------------------------
/test/index.js:
--------------------------------------------------------------------------------
1 | //
2 | // PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING
3 | //
4 | // This file is providing the test runner to use when running extension tests.
5 | // By default the test runner in use is Mocha based.
6 | //
7 | // You can provide your own test runner if you want to override it by exporting
8 | // a function run(testRoot: string, clb: (error:Error) => void) that the extension
9 | // host can call to run the tests. The test runner is expected to use console.log
10 | // to report the results back to the caller. When the tests are finished, return
11 | // a possible error to the callback or null if none.
12 |
13 | var testRunner = require('vscode/lib/testrunner');
14 |
15 | // You can directly control Mocha options by uncommenting the following lines
16 | // See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info
17 | testRunner.configure({
18 | ui: 'tdd', // the TDD UI is being used in extension.test.js (suite, test, etc.)
19 | useColors: true // colored output from test results
20 | });
21 |
22 | module.exports = testRunner;
--------------------------------------------------------------------------------
/typings/node.d.ts:
--------------------------------------------------------------------------------
1 | ///
--------------------------------------------------------------------------------
/typings/vscode-typings.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/vsc-extension-quickstart.md:
--------------------------------------------------------------------------------
1 | # Welcome to your first VS Code Extension
2 |
3 | ## What's in the folder
4 | * This folder contains all of the files necessary for your extension
5 | * `package.json` - this is the manifest file in which you declare your extension and command.
6 | The sample plugin registers a command and defines its title and command name. With this information
7 | VS Code can show the command in the command palette. It doesn’t yet need to load the plugin.
8 | * `extension.js` - this is the main file where you will provide the implementation of your command.
9 | The file exports one function, `activate`, which is called the very first time your extension is
10 | activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`.
11 | We pass the function containing the implementation of the command as the second parameter to
12 | `registerCommand`.
13 |
14 | ## Get up and running straight away
15 | * press `F5` to open a new window with your extension loaded
16 | * run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World`
17 | * set breakpoints in your code inside extension.ts to debug your extension
18 | * find output from your extension in the debug console
19 |
20 | ## Make changes
21 | * you can relaunch the extension from the debug toolbar after changing code in `extension.js`
22 | * you can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes
23 |
24 | ## Explore the API
25 | * you can open the full set of our API when you open the file `node_modules/vscode/vscode.d.ts`
26 |
27 | ## Run tests
28 | * open the debug viewlet (`Ctrl+Shift+D` or `Cmd+Shift+D` on Mac) and from the launch configuration dropdown pick `Launch Tests`
29 | * press `F5` to run the tests in a new window with your extension loaded
30 | * see the output of the test result in the debug console
31 | * make changes to `test/extension.test.js` or create new test files inside the `test` folder
32 | * by convention, the test runner will only consider files matching the name pattern `**.test.js`
33 | * you can create folders inside the `test` folder to structure your tests any way you want
--------------------------------------------------------------------------------