Skip to content

Commit 5a2a702

Browse files
Fix jake task, style/const in script.
1 parent 37ee17d commit 5a2a702

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

Jakefile.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ function concatenateFiles(destinationFile, sourceFiles) {
206206
var useDebugMode = true;
207207
var host = (process.env.host || process.env.TYPESCRIPT_HOST || "node");
208208
var compilerFilename = "tsc.js";
209+
var LKGCompiler = path.join(LKGDirectory, compilerFilename);
210+
var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename);
211+
209212
/* Compiles a file from a list of sources
210213
* @param outFile: the target file name
211214
* @param sources: an array of the names of the source files
@@ -220,7 +223,7 @@ var compilerFilename = "tsc.js";
220223
*/
221224
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, outDir, preserveConstEnums, keepComments, noResolve, stripInternal, callback) {
222225
file(outFile, prereqs, function() {
223-
var dir = useBuiltCompiler ? builtLocalDirectory : LKGDirectory;
226+
var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler;
224227
var options = "--module commonjs --noImplicitAny --noEmitOnError";
225228

226229
// Keep comments when specifically requested
@@ -257,7 +260,7 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOu
257260
options += " --stripInternal"
258261
}
259262

260-
var cmd = host + " " + dir + compilerFilename + " " + options + " ";
263+
var cmd = host + " " + compilerPath + " " + options + " ";
261264
cmd = cmd + sources.join(" ");
262265
console.log(cmd + "\n");
263266

@@ -328,7 +331,7 @@ compileFile(processDiagnosticMessagesJs,
328331

329332
// The generated diagnostics map; built for the compiler and for the 'generate-diagnostics' task
330333
file(diagnosticInfoMapTs, [processDiagnosticMessagesJs, diagnosticMessagesJson], function () {
331-
var cmd = "node " + processDiagnosticMessagesJs + " " + diagnosticMessagesJson;
334+
var cmd = host + " " + processDiagnosticMessagesJs + " " + diagnosticMessagesJson;
332335
console.log(cmd);
333336
var ex = jake.createExec([cmd]);
334337
// Add listeners for output and error
@@ -374,7 +377,7 @@ task("setDebugMode", function() {
374377
});
375378

376379
task("configure-nightly", [configureNightlyJs], function() {
377-
var cmd = "node " + configureNightlyJs + " " + packageJson + " " + programTs;
380+
var cmd = host + " " + configureNightlyJs + " " + packageJson + " " + programTs;
378381
console.log(cmd);
379382
exec(cmd);
380383
}, { async: true });
@@ -399,13 +402,18 @@ var importDefinitelyTypedTestsDirectory = path.join(scriptsDirectory, "importDef
399402
var importDefinitelyTypedTestsJs = path.join(importDefinitelyTypedTestsDirectory, "importDefinitelyTypedTests.js");
400403
var importDefinitelyTypedTestsTs = path.join(importDefinitelyTypedTestsDirectory, "importDefinitelyTypedTests.ts");
401404

402-
file(importDefinitelyTypedTestsJs);
403-
file(importDefinitelyTypedTestsTs, ["tsd-scripts", importDefinitelyTypedTestsJs])
404-
task("importDefinitelyTyped", importDefinitelyTypedTestsTs, function () {
405-
var cmd = "node " + importDefinitelyTypedTestsJs + " ./ ../DefinitelyTyped";
405+
file(importDefinitelyTypedTestsTs);
406+
file(importDefinitelyTypedTestsJs, ["tsd-scripts", importDefinitelyTypedTestsTs], function () {
407+
var cmd = host + " " + LKGCompiler + " -p " + importDefinitelyTypedTestsDirectory;
406408
console.log(cmd);
407409
exec(cmd);
408-
}, { async: true })
410+
}, { async: true });
411+
412+
task("importDefinitelyTypedTests", [importDefinitelyTypedTestsJs], function () {
413+
var cmd = host + " " + importDefinitelyTypedTestsJs + " ./ ../DefinitelyTyped";
414+
console.log(cmd);
415+
exec(cmd);
416+
}, { async: true });
409417

410418
// Local target to build the compiler and services
411419
var tscFile = path.join(builtLocalDirectory, compilerFilename);

scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,12 @@ function importDefinitelyTypedTests(tscPath: string, rwcTestPath: string, defini
107107
throw err;
108108
}
109109

110+
// When you just want to test the script out on one or two files,
111+
// just add a line like the following:
112+
//
113+
// .filter(d => d.indexOf("sipml") >= 0 )
110114
subDirectories
111115
.filter(d => ["_infrastructure", "node_modules", ".git"].indexOf(d) < 0)
112-
// .filter(i => i.indexOf("sipml") >= 0 ) // Uncomment when you want to test :)
113116
.filter(i => fs.statSync(path.join(definitelyTypedRoot, i)).isDirectory())
114117
.forEach(d => {
115118
const directoryPath = path.join(definitelyTypedRoot, d);
@@ -137,7 +140,7 @@ function importDefinitelyTypedTests(tscPath: string, rwcTestPath: string, defini
137140

138141
if (testFiles.length === 0) {
139142
// no test files but multiple d.ts's, e.g. winjs
140-
let regexp = new RegExp(d + "(([-][0-9])|([\.]d[\.]ts))");
143+
const regexp = new RegExp(d + "(([-][0-9])|([\.]d[\.]ts))");
141144
if (tsFiles.length > 1 && tsFiles.every(t => filePathEndsWith(t, ".d.ts") && regexp.test(t))) {
142145
for (const fileName of tsFiles) {
143146
importDefinitelyTypedTest(tscPath, rwcTestPath, path.basename(fileName, ".d.ts"), [fileName], paramFile);

0 commit comments

Comments
 (0)