Skip to content

Commit 41567b2

Browse files
committed
Migrate tscWatchMode to vfs
1 parent 3d3977f commit 41567b2

35 files changed

+5585
-2950
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.js
4646
scripts/generateLocalizedDiagnosticMessages.js
4747
scripts/*.js.map
4848
scripts/typings/
49+
scripts/typemock/dist
4950
coverage/
5051
internal/
5152
**/.DS_Store

.vscode/tasks.json

+26-22
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
1-
// Available variables which can be used inside of strings.
2-
// ${workspaceRoot}: the root folder of the team
3-
// ${file}: the current opened file
4-
// ${fileBasename}: the current opened file's basename
5-
// ${fileDirname}: the current opened file's dirname
6-
// ${fileExtname}: the current opened file's extension
7-
// ${cwd}: the current working directory of the spawned process
81
{
9-
"version": "0.1.0",
10-
"command": "gulp",
11-
"isShellCommand": true,
12-
"showOutput": "silent",
2+
// See https://go.microsoft.com/fwlink/?LinkId=733558
3+
// for the documentation about the tasks.json format
4+
"version": "2.0.0",
135
"tasks": [
146
{
15-
"taskName": "local",
16-
"isBuildCommand": true,
17-
"showOutput": "silent",
18-
"problemMatcher": [
19-
"$tsc"
20-
]
7+
"type": "shell",
8+
"identifier": "local",
9+
"label": "gulp: local",
10+
"command": "gulp",
11+
"args": ["local"],
12+
"group": { "kind": "build", "isDefault": true },
13+
"problemMatcher": ["$gulp-tsc"]
2114
},
2215
{
23-
"taskName": "tests",
24-
"showOutput": "silent",
25-
"problemMatcher": [
26-
"$tsc"
27-
]
16+
"type": "shell",
17+
"identifier": "tsc",
18+
"label": "gulp: tsc",
19+
"command": "gulp",
20+
"args": ["tsc"],
21+
"group": "build",
22+
"problemMatcher": ["$gulp-tsc"]
23+
},
24+
{
25+
"type": "shell",
26+
"identifier": "tests",
27+
"label": "gulp: tests",
28+
"command": "gulp",
29+
"args": ["tests"],
30+
"group": "build",
31+
"problemMatcher": ["$gulp-tsc"]
2832
}
2933
]
3034
}

Gulpfile.ts

+23-4
Original file line numberDiff line numberDiff line change
@@ -602,10 +602,19 @@ gulp.task("LKG", "Makes a new LKG out of the built js files", ["clean", "dontUse
602602
return runSequence("LKGInternal", "VerifyLKG");
603603
});
604604

605+
gulp.task("typemock", () => {
606+
const typemock = tsc.createProject("scripts/typemock/src/tsconfig.json", getCompilerSettings({}, /*useBuiltCompiler*/ true));
607+
return typemock.src()
608+
.pipe(sourcemaps.init())
609+
.pipe(newer("scripts/typemock/dist"))
610+
.pipe(typemock())
611+
.pipe(sourcemaps.write(".", <any>{ includeContent: false, destPath: "scripts/typemock/dist" }))
612+
.pipe(gulp.dest("scripts/typemock/dist"));
613+
});
605614

606615
// Task to build the tests infrastructure using the built compiler
607616
const run = path.join(builtLocalDirectory, "run.js");
608-
gulp.task(run, /*help*/ false, [servicesFile, tsserverLibraryFile], () => {
617+
gulp.task(run, /*help*/ false, [servicesFile, tsserverLibraryFile, "typemock"], () => {
609618
const testProject = tsc.createProject("src/harness/tsconfig.json", getCompilerSettings({}, /*useBuiltCompiler*/ true));
610619
return testProject.src()
611620
.pipe(newer(run))
@@ -644,7 +653,7 @@ function restoreSavedNodeEnv() {
644653
process.env.NODE_ENV = savedNodeEnv;
645654
}
646655

647-
function runConsoleTests(defaultReporter: string, runInParallel: boolean, done: (e?: any) => void) {
656+
function runConsoleTests(defaultReporter: string, runInParallel: boolean, done: (e?: any) => void, noExit?: boolean) {
648657
const lintFlag = cmdLineOptions.lint;
649658
cleanTestDirs((err) => {
650659
if (err) { console.error(err); failWithStatus(err, 1); }
@@ -720,8 +729,10 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
720729
});
721730

722731
function failWithStatus(err?: any, status?: number) {
723-
if (err || status) {
724-
process.exit(typeof status === "number" ? status : 2);
732+
if (!noExit) {
733+
if (err || status) {
734+
process.exit(typeof status === "number" ? status : 2);
735+
}
725736
}
726737
done();
727738
}
@@ -762,6 +773,10 @@ gulp.task("runtests",
762773
runConsoleTests("mocha-fivemat-progress-reporter", /*runInParallel*/ false, done);
763774
});
764775

776+
gulp.task("runtests-in-watch", ["build-rules", "tests"], done => {
777+
runConsoleTests("min", /*runInParallel*/ false, done, /*noExit*/ true);
778+
});
779+
765780
const nodeServerOutFile = "tests/webTestServer.js";
766781
const nodeServerInFile = "tests/webTestServer.ts";
767782
gulp.task(nodeServerOutFile, /*help*/ false, [servicesFile], () => {
@@ -1110,3 +1125,7 @@ gulp.task("default", "Runs 'local'", ["local"]);
11101125
gulp.task("watch", "Watches the src/ directory for changes and executes runtests-parallel.", [], () => {
11111126
gulp.watch("src/**/*.*", ["runtests-parallel"]);
11121127
});
1128+
1129+
gulp.task("watch-no-parallel", "Watches the src/ directory for changes and executes runtests.", [], () => {
1130+
gulp.watch(["src/**/*.*", "scripts/typemock/src/**/*.*"], ["runtests-in-watch"]);
1131+
});

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,13 @@
4848
"@types/node": "latest",
4949
"@types/q": "latest",
5050
"@types/run-sequence": "latest",
51+
"@types/source-map-support": "^0.4.0",
5152
"@types/through2": "latest",
5253
"@types/xml2js": "^0.4.0",
53-
"xml2js": "^0.4.19",
5454
"browser-resolve": "^1.11.2",
5555
"browserify": "latest",
5656
"chai": "latest",
57+
"colors": "latest",
5758
"convert-source-map": "latest",
5859
"del": "latest",
5960
"gulp": "3.X",
@@ -79,9 +80,9 @@
7980
"travis-fold": "latest",
8081
"ts-node": "latest",
8182
"tslint": "latest",
83+
"typescript": "next",
8284
"vinyl": "latest",
83-
"colors": "latest",
84-
"typescript": "next"
85+
"xml2js": "^0.4.19"
8586
},
8687
"scripts": {
8788
"pretest": "jake tests",

scripts/typemock/gulpfile.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const gulp = require("gulp");
2+
const gutil = require("gulp-util");
3+
const sourcemaps = require("gulp-sourcemaps");
4+
const tsb = require("gulp-tsb");
5+
const mocha = require("gulp-mocha");
6+
const del = require("del");
7+
8+
const src = {
9+
compile: tsb.create("src/tsconfig.json"),
10+
src: () => gulp.src(["src/**/*.ts"]),
11+
dest: () => gulp.dest("dist")
12+
};
13+
14+
gulp.task("clean", () => del(["dist/**/*"]));
15+
16+
gulp.task("build", () => src.src()
17+
.pipe(sourcemaps.init())
18+
.pipe(src.compile())
19+
.pipe(sourcemaps.write(".", { includeContent: false, destPath: "dist" }))
20+
.pipe(gulp.dest("dist")));
21+
22+
gulp.task("test", ["build"], () => gulp
23+
.src(["dist/tests/index.js"], { read: false })
24+
.pipe(mocha({ reporter: "dot" })));
25+
26+
27+
gulp.task("watch", ["test"], () => gulp.watch(["src/**/*"], ["test"]));
28+
29+
gulp.task("default", ["test"]);

scripts/typemock/package.json

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"private": true,
3+
"name": "typemock",
4+
"version": "0.0.0",
5+
"description": "JavaScript Mock object framework",
6+
"main": "dist/index.js",
7+
"types": "dist/index.d.ts",
8+
"scripts": {
9+
"test": "gulp test"
10+
},
11+
"keywords": [
12+
"javascript",
13+
"mock",
14+
"type",
15+
"typescript"
16+
],
17+
"author": "Ron Buckton ([email protected])",
18+
"license": "Apache-2.0",
19+
"devDependencies": {
20+
"@types/chai": "^4.0.4",
21+
"@types/mocha": "^2.2.27",
22+
"@types/node": "^8.0.20",
23+
"@types/source-map-support": "^0.4.0",
24+
"chai": "^4.1.2",
25+
"del": "^2.0.2",
26+
"gulp": "^3.9.1",
27+
"gulp-mocha": "^4.3.1",
28+
"gulp-sourcemaps": "^2.6.1",
29+
"gulp-tsb": "^2.0.5",
30+
"merge2": "^0.3.6",
31+
"mocha": "^2.2.5",
32+
"source-map-support": "^0.5.0",
33+
"typescript": "^2.6.1"
34+
}
35+
}

0 commit comments

Comments
 (0)