Skip to content

Commit 64a225a

Browse files
committed
Merge branch 'master' into promised
2 parents b5cde15 + 31230b9 commit 64a225a

File tree

624 files changed

+217975
-193104
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

624 files changed

+217975
-193104
lines changed

Gulpfile.ts

+61-37
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import minimist = require("minimist");
2828
import browserify = require("browserify");
2929
import through2 = require("through2");
3030
import merge2 = require("merge2");
31-
import intoStream = require("into-stream");
3231
import * as os from "os";
3332
import fold = require("travis-fold");
3433
const gulp = helpMaker(originalGulp);
@@ -294,7 +293,7 @@ gulp.task("configure-nightly", "Runs scripts/configureNightly.ts to prepare a bu
294293
exec(host, [configureNightlyJs, packageJson, versionFile], done, done);
295294
});
296295
gulp.task("publish-nightly", "Runs `npm publish --tag next` to create a new nightly build on npm", ["LKG"], () => {
297-
return runSequence("clean", "useDebugMode", "runtests", (done) => {
296+
return runSequence("clean", "useDebugMode", "runtests-parallel", (done) => {
298297
exec("npm", ["publish", "--tag", "next"], done, done);
299298
});
300299
});
@@ -737,50 +736,75 @@ gulp.task(nodeServerOutFile, /*help*/ false, [servicesFile], () => {
737736

738737
import convertMap = require("convert-source-map");
739738
import sorcery = require("sorcery");
740-
declare module "convert-source-map" {
741-
export function fromSource(source: string, largeSource?: boolean): SourceMapConverter;
742-
}
739+
import Vinyl = require("vinyl");
743740

744-
gulp.task("browserify", "Runs browserify on run.js to produce a file suitable for running tests in the browser", [servicesFile, run], (done) => {
745-
const testProject = tsc.createProject("src/harness/tsconfig.json", getCompilerSettings({ outFile: "../../built/local/bundle.js" }, /*useBuiltCompiler*/ true));
746-
return testProject.src()
747-
.pipe(newer("built/local/bundle.js"))
741+
const bundlePath = path.resolve("built/local/bundle.js");
742+
743+
gulp.task("browserify", "Runs browserify on run.js to produce a file suitable for running tests in the browser", [servicesFile], (done) => {
744+
const testProject = tsc.createProject("src/harness/tsconfig.json", getCompilerSettings({ outFile: bundlePath, inlineSourceMap: true }, /*useBuiltCompiler*/ true));
745+
let originalMap: any;
746+
let prebundledContent: string;
747+
browserify(testProject.src()
748+
.pipe(newer(bundlePath))
748749
.pipe(sourcemaps.init())
749750
.pipe(testProject())
750751
.pipe(through2.obj((file, enc, next) => {
751-
const originalMap = file.sourceMap;
752-
const prebundledContent = file.contents.toString();
752+
if (originalMap) {
753+
throw new Error("Should only recieve one file!");
754+
}
755+
console.log(`Saving sourcemaps for ${file.path}`);
756+
originalMap = file.sourceMap;
757+
prebundledContent = file.contents.toString();
753758
// Make paths absolute to help sorcery deal with all the terrible paths being thrown around
754759
originalMap.sources = originalMap.sources.map(s => path.resolve(path.join("src/harness", s)));
755-
// intoStream (below) makes browserify think the input file is named this, so this is what it puts in the sourcemap
760+
// browserify names input files this when they are streamed in, so this is what it puts in the sourcemap
756761
originalMap.file = "built/local/_stream_0.js";
757762

758-
browserify(intoStream(file.contents), { debug: true })
759-
.bundle((err, res) => {
760-
// assumes file.contents is a Buffer
761-
const maps = JSON.parse(convertMap.fromSource(res.toString(), /*largeSource*/ true).toJSON());
762-
delete maps.sourceRoot;
763-
maps.sources = maps.sources.map(s => path.resolve(s === "_stream_0.js" ? "built/local/_stream_0.js" : s));
764-
// Strip browserify's inline comments away (could probably just let sorcery do this, but then we couldn't fix the paths)
765-
file.contents = new Buffer(convertMap.removeComments(res.toString()));
766-
const chain = sorcery.loadSync("built/local/bundle.js", {
767-
content: {
768-
"built/local/_stream_0.js": prebundledContent,
769-
"built/local/bundle.js": file.contents.toString()
770-
},
771-
sourcemaps: {
772-
"built/local/_stream_0.js": originalMap,
773-
"built/local/bundle.js": maps,
774-
"node_modules/source-map-support/source-map-support.js": undefined,
775-
}
776-
});
777-
const finalMap = chain.apply();
778-
file.sourceMap = finalMap;
779-
next(/*err*/ undefined, file);
780-
});
763+
next(/*err*/ undefined, file.contents);
781764
}))
782-
.pipe(sourcemaps.write(".", { includeContent: false }))
783-
.pipe(gulp.dest("src/harness"));
765+
.on("error", err => {
766+
return done(err);
767+
}), { debug: true, basedir: __dirname }) // Attach error handler to inner stream
768+
.bundle((err, contents) => {
769+
if (err) {
770+
if (err.message.match(/Cannot find module '.*_stream_0.js'/)) {
771+
return done(); // Browserify errors when we pass in no files when `newer` filters the input, we should count that as a success, though
772+
}
773+
return done(err);
774+
}
775+
const stringContent = contents.toString();
776+
const file = new Vinyl({ contents, path: bundlePath });
777+
console.log(`Fixing sourcemaps for ${file.path}`);
778+
// assumes contents is a Buffer, since that's what browserify yields
779+
const maps = convertMap.fromSource(stringContent, /*largeSource*/ true).toObject();
780+
delete maps.sourceRoot;
781+
maps.sources = maps.sources.map(s => path.resolve(s === "_stream_0.js" ? "built/local/_stream_0.js" : s));
782+
// Strip browserify's inline comments away (could probably just let sorcery do this, but then we couldn't fix the paths)
783+
file.contents = new Buffer(convertMap.removeComments(stringContent));
784+
const chain = sorcery.loadSync(bundlePath, {
785+
content: {
786+
"built/local/_stream_0.js": prebundledContent,
787+
[bundlePath]: stringContent
788+
},
789+
sourcemaps: {
790+
"built/local/_stream_0.js": originalMap,
791+
[bundlePath]: maps,
792+
"node_modules/source-map-support/source-map-support.js": undefined,
793+
}
794+
});
795+
const finalMap = chain.apply();
796+
file.sourceMap = finalMap;
797+
798+
const stream = through2.obj((file, enc, callback) => {
799+
return callback(/*err*/ undefined, file);
800+
});
801+
stream.pipe(sourcemaps.write(".", { includeContent: false }))
802+
.pipe(gulp.dest("."))
803+
.on("end", done)
804+
.on("error", done);
805+
stream.write(file);
806+
stream.end();
807+
});
784808
});
785809

786810

Jakefile.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ task("configure-nightly", [configureNightlyJs], function () {
505505
}, { async: true });
506506

507507
desc("Configure, build, test, and publish the nightly release.");
508-
task("publish-nightly", ["configure-nightly", "LKG", "clean", "setDebugMode", "runtests"], function () {
508+
task("publish-nightly", ["configure-nightly", "LKG", "clean", "setDebugMode", "runtests-parallel"], function () {
509509
var cmd = "npm publish --tag next";
510510
console.log(cmd);
511511
exec(cmd);
@@ -840,7 +840,8 @@ function runConsoleTests(defaultReporter, runInParallel) {
840840
testTimeout = 800000;
841841
}
842842

843-
var colors = process.env.colors || process.env.color || true;
843+
var colorsFlag = process.env.color || process.env.colors;
844+
var colors = colorsFlag !== "false" && colorsFlag !== "0";
844845
var reporter = process.env.reporter || process.env.r || defaultReporter;
845846
var bail = process.env.bail || process.env.b;
846847
var lintFlag = process.env.lint !== 'false';

issue_template.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
```ts
1010
// A *self-contained* demonstration of the problem follows...
11-
11+
// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.
1212
```
1313

1414
**Expected behavior:**

lib/cancellationToken.js

-2
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,3 @@ function createCancellationToken(args) {
6969
}
7070
}
7171
module.exports = createCancellationToken;
72-
73-
//# sourceMappingURL=cancellationToken.js.map

0 commit comments

Comments
 (0)