Skip to content
This repository was archived by the owner on Nov 18, 2022. It is now read-only.

Commit 0f71788

Browse files
authored
Merge pull request #614 from Xanewok/migrate-to-types-vscode
Migrate to @types/vscode
2 parents 8d87000 + 69d64bb commit 0f71788

File tree

10 files changed

+844
-1797
lines changed

10 files changed

+844
-1797
lines changed

.vscodeignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
.vscode/**
22
.vscode-test/**
33
fixtures/**
4+
test/**
45
out/test/**
56
src/**
67
.gitignore
8+
.prettierignore
9+
prettier.config.js
710
vsc-extension-quickstart.md
811
**/tsconfig.json
912
**/tslint.json

package-lock.json

Lines changed: 781 additions & 1763 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,30 +38,33 @@
3838
"onLanguage:rust",
3939
"workspaceContains:Cargo.toml"
4040
],
41-
"main": "./out/extension.js",
41+
"main": "./out/src/extension.js",
4242
"scripts": {
4343
"vscode:prepublish": "npm run check:version && npm run lint && npm run compile",
4444
"compile": "tsc -p ./",
4545
"watch": "tsc -watch -p ./",
4646
"lint": "tslint --config ./tslint.json './src/**/*.ts'",
47-
"test": "npm run compile && node ./node_modules/vscode/bin/test",
47+
"test": "node ./out/test/runTest.js",
4848
"prettier": "prettier **/*.ts",
4949
"check:version": "node cmd/check-version.js",
50-
"postinstall": "node ./node_modules/vscode/bin/install",
5150
"installDevExtension": "npm install && ./node_modules/.bin/vsce package -o ./out/rls-vscode-dev.vsix && code --install-extension ./out/rls-vscode-dev.vsix"
5251
},
5352
"dependencies": {
5453
"vscode-languageclient": "^4.3.0"
5554
},
5655
"devDependencies": {
57-
"@types/mocha": "^2.2.43",
56+
"@types/glob": "^7.1.1",
57+
"@types/mocha": "^5.2.6",
5858
"@types/node": "~10.1.0",
59+
"@types/vscode": "^1.31.0",
60+
"glob": "^7.1.4",
61+
"mocha": "^6.1.4",
5962
"prettier": "^1.16.4",
6063
"tslint": "^5.14.0",
6164
"tslint-config-prettier": "^1.18.0",
6265
"typescript": "^3.0.0",
63-
"vsce": "^1.58.0",
64-
"vscode": "^1.1.30"
66+
"vsce": "^1.63.0",
67+
"vscode-test": "^0.4.3"
6568
},
6669
"contributes": {
6770
"languages": [

src/test/index.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

test/runTest.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import * as path from 'path';
2+
// tslint:disable-next-line: no-implicit-dependencies
3+
import { runTests } from 'vscode-test';
4+
5+
(async () => {
6+
const extensionPath = path.resolve(__dirname, '../../');
7+
const testRunnerPath = path.resolve(__dirname, './suite');
8+
9+
await runTests({
10+
extensionPath,
11+
testRunnerPath,
12+
});
13+
})();

src/test/extension.test.ts renamed to test/suite/extension.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import * as vscode from 'vscode';
44
// tslint:disable-next-line: no-duplicate-imports
55
import { Uri } from 'vscode';
66

7-
const fixtureDir = path.resolve(path.join(__dirname, '..', '..', 'fixtures'));
7+
const fixtureDir = path.resolve(
8+
path.join(__dirname, '..', '..', '..', 'fixtures'),
9+
);
810

911
suite('Extension Tests', () => {
1012
test('cargo tasks are auto-detected', async () => {

test/suite/index.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import * as glob from 'glob';
2+
import * as Mocha from 'mocha';
3+
import * as path from 'path';
4+
5+
export function run(
6+
testsRoot: string,
7+
// tslint:disable-next-line: no-any
8+
cb: (error: any, failures?: number) => void,
9+
): void {
10+
// Create the mocha test
11+
const mocha = new Mocha({
12+
ui: 'tdd',
13+
}).useColors(true);
14+
15+
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
16+
if (err) {
17+
return cb(err);
18+
}
19+
20+
// Add files to the test suite
21+
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
22+
23+
try {
24+
// Run the mocha test
25+
mocha.run(failures => {
26+
cb(null, failures);
27+
});
28+
} catch (err) {
29+
cb(err);
30+
}
31+
});
32+
}

src/test/rustup.test.ts renamed to test/suite/rustup.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as assert from 'assert';
22
import * as child_process from 'child_process';
33

4-
import * as rustup from '../rustup';
4+
import * as rustup from '../../src/rustup';
55

66
// We need to ensure that rustup works and is installed
77
const rustupVersion = child_process.execSync('rustup --version').toString();

src/test/utils/wslpath.test.ts renamed to test/suite/utils/wslpath.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as assert from 'assert';
22

3-
import * as wslpath from '../../utils/wslpath';
3+
import * as wslpath from '../../../src/utils/wslpath';
44

55
function mkConverterCheck(converter: (arg: string) => string) {
66
return (from: string, to: string) => assert.equal(converter(from), to);

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
"outDir": "out",
66
"lib": ["es6"],
77
"sourceMap": true,
8-
"rootDir": "src",
98
"strict": true,
109
"noUnusedLocals": true,
1110
"noUnusedParameters": true,
1211
"noImplicitReturns": true,
1312
"noFallthroughCasesInSwitch": true
1413
},
14+
"include": ["src", "test"],
1515
"exclude": [
1616
"node_modules",
1717
".vscode-test"

0 commit comments

Comments
 (0)