From 1500f5cd029e849de938a93ce8bc5690fe7179fd Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 16 Sep 2015 17:28:30 -0700 Subject: [PATCH 01/10] Moved importDefinitelyTypedTests.ts to its own folder. --- .../importDefinitelyTypedTests.ts | 3 --- 1 file changed, 3 deletions(-) rename scripts/{ => importDefinitelyTypedTests}/importDefinitelyTypedTests.ts (95%) diff --git a/scripts/importDefinitelyTypedTests.ts b/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts similarity index 95% rename from scripts/importDefinitelyTypedTests.ts rename to scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts index f33ba1dd525..518fbed87b8 100644 --- a/scripts/importDefinitelyTypedTests.ts +++ b/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts @@ -1,6 +1,3 @@ -declare var require: any, process: any; -declare var __dirname: any; - var fs = require("fs"); var path = require("path"); var child_process = require('child_process'); From 9696e5777253e397b151816c31d8a780776027d5 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 16 Sep 2015 17:34:31 -0700 Subject: [PATCH 02/10] Added tsd.json file with 'node.d.ts'. --- scripts/tsd.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 scripts/tsd.json diff --git a/scripts/tsd.json b/scripts/tsd.json new file mode 100644 index 00000000000..c2fc88a0b0f --- /dev/null +++ b/scripts/tsd.json @@ -0,0 +1,12 @@ +{ + "version": "v4", + "repo": "borisyankov/DefinitelyTyped", + "ref": "master", + "path": "typings", + "bundle": "typings/tsd.d.ts", + "installed": { + "node/node.d.ts": { + "commit": "5f480287834a2615274eea31574b713e64decf17" + } + } +} From a47b7b8f1764afeed1a520e6bdab25a4e29788e3 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 16 Sep 2015 17:35:18 -0700 Subject: [PATCH 03/10] Added 'tsconfig.json' for 'importDefinitelyTypedTests' script. --- scripts/importDefinitelyTypedTests/tsconfig.json | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 scripts/importDefinitelyTypedTests/tsconfig.json diff --git a/scripts/importDefinitelyTypedTests/tsconfig.json b/scripts/importDefinitelyTypedTests/tsconfig.json new file mode 100644 index 00000000000..3bf148ffa5c --- /dev/null +++ b/scripts/importDefinitelyTypedTests/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es3", + "noImplicitAny": true, + "outDir": "./", + "rootDir": ".", + "sourceMap": false + }, + "files": [ + "../typings/node/node.d.ts", + "importDefinitelyTypedTests.ts" + ], + "exclude": [ + ] +} \ No newline at end of file From 8bb6313b22b9b7a0c1d5b0d04156589d181e64e3 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 16 Sep 2015 17:42:32 -0700 Subject: [PATCH 04/10] Use explicit types, var -> let/const, misspellings, style. --- .../importDefinitelyTypedTests.ts | 70 ++++++++++++------- 1 file changed, 43 insertions(+), 27 deletions(-) diff --git a/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts b/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts index 518fbed87b8..fa935c2fa31 100644 --- a/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts +++ b/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts @@ -1,29 +1,41 @@ -var fs = require("fs"); -var path = require("path"); -var child_process = require('child_process'); +import * as fs from "fs"; +import * as path from "path"; +import * as child_process from "child_process"; -var tscRoot = path.join(__dirname, "..\\"); -var tscPath = path.join(tscRoot, "built", "instrumented", "tsc.js"); -var rwcTestPath = path.join(tscRoot, "tests", "cases", "rwc", "dt"); -var definitelyTypedRoot = process.argv[2]; +interface Map { + [key: string]: T; +} + +declare const __dirname: string; +declare const process: { + argv: string[]; + env: Map +} + +const tscRoot = path.join(__dirname, "..\\"); +const tscPath = path.join(tscRoot, "built", "instrumented", "tsc.js"); +const rwcTestPath = path.join(tscRoot, "tests", "cases", "rwc", "dt"); +const definitelyTypedRoot = process.argv[2]; function fileExtensionIs(path: string, extension: string): boolean { - var pathLen = path.length; - var extLen = extension.length; + const pathLen = path.length; + const extLen = extension.length; return pathLen > extLen && path.substr(pathLen - extLen, extLen).toLocaleLowerCase() === extension.toLocaleLowerCase(); } -function copyFileSync(source, destination) { - var text = fs.readFileSync(source); +function copyFileSync(source: string, destination: string) { + let text = fs.readFileSync(source); fs.writeFileSync(destination, text); } function importDefinitelyTypedTest(testCaseName: string, testFiles: string[], responseFile: string ) { - var cmd = "node " + tscPath + " --module commonjs " + testFiles.join(" "); - if (responseFile) cmd += " @" + responseFile; + let cmd = "node " + tscPath + " --module commonjs " + testFiles.join(" "); + if (responseFile) { + cmd += " @" + responseFile; + } - var testDirectoryName = testCaseName + "_" + Math.floor((Math.random() * 10000) + 1); - var testDirectoryPath = path.join(process.env["temp"], testDirectoryName); + let testDirectoryName = testCaseName + "_" + Math.floor((Math.random() * 10000) + 1); + let testDirectoryPath = path.join(process.env["temp"], testDirectoryName); if (fs.existsSync(testDirectoryPath)) { throw new Error("Could not create test directory"); } @@ -47,8 +59,8 @@ function importDefinitelyTypedTest(testCaseName: string, testFiles: string[], re } // copy generated file to output location - var outputFilePath = path.join(testDirectoryPath, "iocapture0.json"); - var testCasePath = path.join(rwcTestPath, "DefinitelyTyped_" + testCaseName + ".json"); + let outputFilePath = path.join(testDirectoryPath, "iocapture0.json"); + let testCasePath = path.join(rwcTestPath, "DefinitelyTyped_" + testCaseName + ".json"); copyFileSync(outputFilePath, testCasePath); //console.log("output generated at: " + outputFilePath); @@ -65,28 +77,32 @@ function importDefinitelyTypedTest(testCaseName: string, testFiles: string[], re //console.log("\r\n"); }) - .on('error', function (error) { + .on('error', (error: any) => { console.log("==> error " + JSON.stringify(error)); console.log("\r\n"); }); } function importDefinitelyTypedTests(definitelyTypedRoot: string): void { - fs.readdir(definitelyTypedRoot, (err, subDirectorys) => { - if (err) throw err; + fs.readdir(definitelyTypedRoot, (err, subDirectories) => { + if (err) { + throw err; + } - subDirectorys + subDirectories .filter(d => ["_infrastructure", "node_modules", ".git"].indexOf(d) < 0) .filter(i => i.indexOf("sipml") >=0 ) .filter(i => fs.statSync(path.join(definitelyTypedRoot, i)).isDirectory()) .forEach(d => { - var directoryPath = path.join(definitelyTypedRoot, d); + let directoryPath = path.join(definitelyTypedRoot, d); fs.readdir(directoryPath, function (err, files) { - if (err) throw err; + if (err) { + throw err; + } - var tsFiles = []; - var testFiles = []; - var paramFile; + let tsFiles: string[] = []; + let testFiles: string[] = []; + let paramFile: string; files .map(f => path.join(directoryPath, f)) @@ -99,7 +115,7 @@ function importDefinitelyTypedTests(definitelyTypedRoot: string): void { if (testFiles.length === 0) { // no test files but multiple d.ts's, e.g. winjs - var regexp = new RegExp(d + "(([-][0-9])|([\.]d[\.]ts))"); + let regexp = new RegExp(d + "(([-][0-9])|([\.]d[\.]ts))"); if (tsFiles.length > 1 && tsFiles.every(t => fileExtensionIs(t, ".d.ts") && regexp.test(t))) { tsFiles.forEach(filename => { importDefinitelyTypedTest(path.basename(filename, ".d.ts"), [filename], paramFile); From 22eef28cbdfc9a39851d456b619869ee2a908a3a Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 17 Sep 2015 14:17:23 -0700 Subject: [PATCH 05/10] forEach -> for-of, and other changes. --- .../importDefinitelyTypedTests.ts | 46 ++++++++++--------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts b/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts index fa935c2fa31..9e3f3183bc8 100644 --- a/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts +++ b/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts @@ -17,10 +17,12 @@ const tscPath = path.join(tscRoot, "built", "instrumented", "tsc.js"); const rwcTestPath = path.join(tscRoot, "tests", "cases", "rwc", "dt"); const definitelyTypedRoot = process.argv[2]; -function fileExtensionIs(path: string, extension: string): boolean { +importDefinitelyTypedTests(definitelyTypedRoot); + +function filePathEndsWith(path: string, endingString: string): boolean { const pathLen = path.length; - const extLen = extension.length; - return pathLen > extLen && path.substr(pathLen - extLen, extLen).toLocaleLowerCase() === extension.toLocaleLowerCase(); + const extLen = endingString.length; + return pathLen > extLen && path.substr(pathLen - extLen, extLen).toLocaleLowerCase() === endingString.toLocaleLowerCase(); } function copyFileSync(source: string, destination: string) { @@ -94,7 +96,7 @@ function importDefinitelyTypedTests(definitelyTypedRoot: string): void { .filter(i => i.indexOf("sipml") >=0 ) .filter(i => fs.statSync(path.join(definitelyTypedRoot, i)).isDirectory()) .forEach(d => { - let directoryPath = path.join(definitelyTypedRoot, d); + const directoryPath = path.join(definitelyTypedRoot, d); fs.readdir(directoryPath, function (err, files) { if (err) { throw err; @@ -104,35 +106,37 @@ function importDefinitelyTypedTests(definitelyTypedRoot: string): void { let testFiles: string[] = []; let paramFile: string; - files - .map(f => path.join(directoryPath, f)) - .forEach(f => { - if (fileExtensionIs(f, ".ts")) tsFiles.push(f); - else if (fileExtensionIs(f, ".tscparams")) paramFile = f; + for (const filePath of files.map(f => path.join(directoryPath, f))) { + if (filePathEndsWith(filePath, ".ts")) { + tsFiles.push(filePath); - if (fileExtensionIs(f, "-tests.ts")) testFiles.push(f); - }); + if (filePathEndsWith(filePath, "-tests.ts")) { + testFiles.push(filePath); + } + } + else if (filePathEndsWith(filePath, ".tscparams")) { + paramFile = filePath; + } + } if (testFiles.length === 0) { // no test files but multiple d.ts's, e.g. winjs let regexp = new RegExp(d + "(([-][0-9])|([\.]d[\.]ts))"); - if (tsFiles.length > 1 && tsFiles.every(t => fileExtensionIs(t, ".d.ts") && regexp.test(t))) { - tsFiles.forEach(filename => { - importDefinitelyTypedTest(path.basename(filename, ".d.ts"), [filename], paramFile); - }); + if (tsFiles.length > 1 && tsFiles.every(t => filePathEndsWith(t, ".d.ts") && regexp.test(t))) { + for (const fileName of tsFiles) { + importDefinitelyTypedTest(path.basename(fileName, ".d.ts"), [fileName], paramFile); + } } else { importDefinitelyTypedTest(d, tsFiles, paramFile); } } else { - testFiles.forEach(filename => { - importDefinitelyTypedTest(path.basename(filename, "-tests.ts"), [filename], paramFile); - }); + for (const fileName of tsFiles) { + importDefinitelyTypedTest(path.basename(fileName, "-tests.ts"), [fileName], paramFile); + } } }); }) }); -} - -importDefinitelyTypedTests(definitelyTypedRoot); \ No newline at end of file +} \ No newline at end of file From 23af2a71639cd642422f4d2309a5ed7853675caa Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 17 Sep 2015 16:37:03 -0700 Subject: [PATCH 06/10] Improved command line interaction for 'importDefinitelyTypedTests' script. --- .../importDefinitelyTypedTests.ts | 43 +++++++++++++------ 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts b/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts index 9e3f3183bc8..5a9eb885b38 100644 --- a/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts +++ b/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts @@ -2,22 +2,37 @@ import * as fs from "fs"; import * as path from "path"; import * as child_process from "child_process"; + interface Map { [key: string]: T; } -declare const __dirname: string; -declare const process: { +declare var process: { argv: string[]; - env: Map + env: Map; + exit(exitCode?: number): void; } -const tscRoot = path.join(__dirname, "..\\"); -const tscPath = path.join(tscRoot, "built", "instrumented", "tsc.js"); -const rwcTestPath = path.join(tscRoot, "tests", "cases", "rwc", "dt"); -const definitelyTypedRoot = process.argv[2]; +main(); +function main() { + const [, progName, tscRoot, definitelyTypedRoot] = process.argv; + if (process.argv.length !== 4) { + if (process.argv.length < 2) { + throw "Expected at least 2 argv elements." + } + console.log("Usage:") + console.log(` node ${path.relative(__dirname, progName)} [TypeScript Repo Root] [DefinitelyTyped Repo Root]`); + return; + } -importDefinitelyTypedTests(definitelyTypedRoot); + const tscPath = path.resolve(tscRoot, "built", "local", "tsc.js"); + const rwcTestPath = path.resolve(tscRoot, "tests", "cases", "rwc", "dt"); + const resolvedDefinitelyTypedRoot = path.resolve(definitelyTypedRoot); + + console.log(`Resolved TypeScript Repo Root: '${tscRoot}'.`); + console.log(`Resolved DefinitelyTyped Repo Root: '${definitelyTypedRoot}'.`); + importDefinitelyTypedTests(tscPath, rwcTestPath, resolvedDefinitelyTypedRoot); +} function filePathEndsWith(path: string, endingString: string): boolean { const pathLen = path.length; @@ -27,10 +42,10 @@ function filePathEndsWith(path: string, endingString: string): boolean { function copyFileSync(source: string, destination: string) { let text = fs.readFileSync(source); - fs.writeFileSync(destination, text); + fs.writeFileSync(destination, text, {}); } -function importDefinitelyTypedTest(testCaseName: string, testFiles: string[], responseFile: string ) { +function importDefinitelyTypedTest(tscPath: string, rwcTestPath: string, testCaseName: string, testFiles: string[], responseFile: string ) { let cmd = "node " + tscPath + " --module commonjs " + testFiles.join(" "); if (responseFile) { cmd += " @" + responseFile; @@ -85,7 +100,7 @@ function importDefinitelyTypedTest(testCaseName: string, testFiles: string[], re }); } -function importDefinitelyTypedTests(definitelyTypedRoot: string): void { +function importDefinitelyTypedTests(tscPath: string, rwcTestPath: string, definitelyTypedRoot: string): void { fs.readdir(definitelyTypedRoot, (err, subDirectories) => { if (err) { throw err; @@ -124,16 +139,16 @@ function importDefinitelyTypedTests(definitelyTypedRoot: string): void { let regexp = new RegExp(d + "(([-][0-9])|([\.]d[\.]ts))"); if (tsFiles.length > 1 && tsFiles.every(t => filePathEndsWith(t, ".d.ts") && regexp.test(t))) { for (const fileName of tsFiles) { - importDefinitelyTypedTest(path.basename(fileName, ".d.ts"), [fileName], paramFile); + importDefinitelyTypedTest(tscPath, rwcTestPath, path.basename(fileName, ".d.ts"), [fileName], paramFile); } } else { - importDefinitelyTypedTest(d, tsFiles, paramFile); + importDefinitelyTypedTest(tscPath, rwcTestPath, d, tsFiles, paramFile); } } else { for (const fileName of tsFiles) { - importDefinitelyTypedTest(path.basename(fileName, "-tests.ts"), [fileName], paramFile); + importDefinitelyTypedTest(tscPath, rwcTestPath, path.basename(fileName, "-tests.ts"), [fileName], paramFile); } } }); From bf989aa56572663742626477f1bb463af07a74f6 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 17 Sep 2015 17:26:10 -0700 Subject: [PATCH 07/10] Final touches on the script. --- .../importDefinitelyTypedTests.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts b/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts index 5a9eb885b38..1e673c34d32 100644 --- a/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts +++ b/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts @@ -26,11 +26,12 @@ function main() { } const tscPath = path.resolve(tscRoot, "built", "local", "tsc.js"); - const rwcTestPath = path.resolve(tscRoot, "tests", "cases", "rwc", "dt"); + const rwcTestPath = path.resolve(tscRoot, "internal", "cases", "rwc"); const resolvedDefinitelyTypedRoot = path.resolve(definitelyTypedRoot); - console.log(`Resolved TypeScript Repo Root: '${tscRoot}'.`); - console.log(`Resolved DefinitelyTyped Repo Root: '${definitelyTypedRoot}'.`); + console.log(`Resolved TypeScript Compiler Path: '${tscPath}'.`); + console.log(`Resolved TypeScript RWC Path: '${rwcTestPath}'.`); + console.log(`Resolved DefinitelyTyped Repo Root: '${resolvedDefinitelyTypedRoot}'.`); importDefinitelyTypedTests(tscPath, rwcTestPath, resolvedDefinitelyTypedRoot); } @@ -42,7 +43,7 @@ function filePathEndsWith(path: string, endingString: string): boolean { function copyFileSync(source: string, destination: string) { let text = fs.readFileSync(source); - fs.writeFileSync(destination, text, {}); + fs.writeFileSync(destination, text); } function importDefinitelyTypedTest(tscPath: string, rwcTestPath: string, testCaseName: string, testFiles: string[], responseFile: string ) { @@ -108,7 +109,7 @@ function importDefinitelyTypedTests(tscPath: string, rwcTestPath: string, defini subDirectories .filter(d => ["_infrastructure", "node_modules", ".git"].indexOf(d) < 0) - .filter(i => i.indexOf("sipml") >=0 ) + // .filter(i => i.indexOf("sipml") >= 0 ) // Uncomment when you want to test :) .filter(i => fs.statSync(path.join(definitelyTypedRoot, i)).isDirectory()) .forEach(d => { const directoryPath = path.join(definitelyTypedRoot, d); From 925f0843d90956ea27fd3775bf3d1935ea5cf6d4 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 17 Sep 2015 17:55:07 -0700 Subject: [PATCH 08/10] Add a jake task, .gitignore entry, and add tsd as a dev dependency. --- .gitignore | 3 ++- Jakefile.js | 21 +++++++++++++++++++++ package.json | 3 ++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 58a45545939..9a513646e9c 100644 --- a/.gitignore +++ b/.gitignore @@ -28,7 +28,7 @@ tests/services/browser/typescriptServices.js scripts/configureNightly.js scripts/processDiagnosticMessages.d.ts scripts/processDiagnosticMessages.js -scripts/importDefinitelyTypedTests.js +scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.js src/harness/*.js rwc-report.html *.swp @@ -45,6 +45,7 @@ scripts/run.bat scripts/word2md.js scripts/ior.js scripts/*.js.map +scripts/typings/ coverage/ internal/ **/.DS_Store diff --git a/Jakefile.js b/Jakefile.js index 77d81071e66..cdb03d7f778 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -386,6 +386,27 @@ task("publish-nightly", ["configure-nightly", "LKG", "clean", "setDebugMode", "r exec(cmd); }); +var scriptsTsdJson = path.join(scriptsDirectory, "tsd.json"); +file(scriptsTsdJson); + +task("tsd-scripts", [scriptsTsdJson], function () { + var cmd = "tsd --config " + scriptsTsdJson + " install"; + console.log(cmd) + exec(cmd); +}, { async: true }) + +var importDefinitelyTypedTestsDirectory = path.join(scriptsDirectory, "importDefinitelyTypedTests"); +var importDefinitelyTypedTestsJs = path.join(importDefinitelyTypedTestsDirectory, "importDefinitelyTypedTests.js"); +var importDefinitelyTypedTestsTs = path.join(importDefinitelyTypedTestsDirectory, "importDefinitelyTypedTests.ts"); + +file(importDefinitelyTypedTestsJs); +file(importDefinitelyTypedTestsTs, ["tsd-scripts", importDefinitelyTypedTestsJs]) +task("importDefinitelyTyped", importDefinitelyTypedTestsTs, function () { + var cmd = "node " + importDefinitelyTypedTestsJs + " ./ ../DefinitelyTyped"; + console.log(cmd); + exec(cmd); +}, { async: true }) + // Local target to build the compiler and services var tscFile = path.join(builtLocalDirectory, compilerFilename); compileFile(tscFile, compilerSources, [builtLocalDirectory, copyright].concat(compilerSources), [copyright], /*useBuiltCompiler:*/ false); diff --git a/package.json b/package.json index b743b04838d..ba8edd188e4 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,8 @@ "browserify": "latest", "istanbul": "latest", "mocha-fivemat-progress-reporter": "latest", - "tslint": "latest" + "tslint": "latest", + "tsd": "latest" }, "scripts": { "pretest": "jake tests", From 37ee17d40d5d04865963fb82ccfb809523d9e1b8 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 17 Sep 2015 17:56:39 -0700 Subject: [PATCH 09/10] es3 -> es5. --- scripts/importDefinitelyTypedTests/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/importDefinitelyTypedTests/tsconfig.json b/scripts/importDefinitelyTypedTests/tsconfig.json index 3bf148ffa5c..dede4572531 100644 --- a/scripts/importDefinitelyTypedTests/tsconfig.json +++ b/scripts/importDefinitelyTypedTests/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "module": "commonjs", - "target": "es3", + "target": "ES5", "noImplicitAny": true, "outDir": "./", "rootDir": ".", From 5a2a7021fa8d9a72881c88c3b8128ab24a67a049 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 18 Sep 2015 13:13:26 -0700 Subject: [PATCH 10/10] Fix jake task, style/const in script. --- Jakefile.js | 26 ++++++++++++------- .../importDefinitelyTypedTests.ts | 7 +++-- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index cdb03d7f778..72844e01cf0 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -206,6 +206,9 @@ function concatenateFiles(destinationFile, sourceFiles) { var useDebugMode = true; var host = (process.env.host || process.env.TYPESCRIPT_HOST || "node"); var compilerFilename = "tsc.js"; +var LKGCompiler = path.join(LKGDirectory, compilerFilename); +var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename); + /* Compiles a file from a list of sources * @param outFile: the target file name * @param sources: an array of the names of the source files @@ -220,7 +223,7 @@ var compilerFilename = "tsc.js"; */ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, outDir, preserveConstEnums, keepComments, noResolve, stripInternal, callback) { file(outFile, prereqs, function() { - var dir = useBuiltCompiler ? builtLocalDirectory : LKGDirectory; + var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler; var options = "--module commonjs --noImplicitAny --noEmitOnError"; // Keep comments when specifically requested @@ -257,7 +260,7 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOu options += " --stripInternal" } - var cmd = host + " " + dir + compilerFilename + " " + options + " "; + var cmd = host + " " + compilerPath + " " + options + " "; cmd = cmd + sources.join(" "); console.log(cmd + "\n"); @@ -328,7 +331,7 @@ compileFile(processDiagnosticMessagesJs, // The generated diagnostics map; built for the compiler and for the 'generate-diagnostics' task file(diagnosticInfoMapTs, [processDiagnosticMessagesJs, diagnosticMessagesJson], function () { - var cmd = "node " + processDiagnosticMessagesJs + " " + diagnosticMessagesJson; + var cmd = host + " " + processDiagnosticMessagesJs + " " + diagnosticMessagesJson; console.log(cmd); var ex = jake.createExec([cmd]); // Add listeners for output and error @@ -374,7 +377,7 @@ task("setDebugMode", function() { }); task("configure-nightly", [configureNightlyJs], function() { - var cmd = "node " + configureNightlyJs + " " + packageJson + " " + programTs; + var cmd = host + " " + configureNightlyJs + " " + packageJson + " " + programTs; console.log(cmd); exec(cmd); }, { async: true }); @@ -399,13 +402,18 @@ var importDefinitelyTypedTestsDirectory = path.join(scriptsDirectory, "importDef var importDefinitelyTypedTestsJs = path.join(importDefinitelyTypedTestsDirectory, "importDefinitelyTypedTests.js"); var importDefinitelyTypedTestsTs = path.join(importDefinitelyTypedTestsDirectory, "importDefinitelyTypedTests.ts"); -file(importDefinitelyTypedTestsJs); -file(importDefinitelyTypedTestsTs, ["tsd-scripts", importDefinitelyTypedTestsJs]) -task("importDefinitelyTyped", importDefinitelyTypedTestsTs, function () { - var cmd = "node " + importDefinitelyTypedTestsJs + " ./ ../DefinitelyTyped"; +file(importDefinitelyTypedTestsTs); +file(importDefinitelyTypedTestsJs, ["tsd-scripts", importDefinitelyTypedTestsTs], function () { + var cmd = host + " " + LKGCompiler + " -p " + importDefinitelyTypedTestsDirectory; console.log(cmd); exec(cmd); -}, { async: true }) +}, { async: true }); + +task("importDefinitelyTypedTests", [importDefinitelyTypedTestsJs], function () { + var cmd = host + " " + importDefinitelyTypedTestsJs + " ./ ../DefinitelyTyped"; + console.log(cmd); + exec(cmd); +}, { async: true }); // Local target to build the compiler and services var tscFile = path.join(builtLocalDirectory, compilerFilename); diff --git a/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts b/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts index 1e673c34d32..1ae3725fff2 100644 --- a/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts +++ b/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts @@ -107,9 +107,12 @@ function importDefinitelyTypedTests(tscPath: string, rwcTestPath: string, defini throw err; } + // When you just want to test the script out on one or two files, + // just add a line like the following: + // + // .filter(d => d.indexOf("sipml") >= 0 ) subDirectories .filter(d => ["_infrastructure", "node_modules", ".git"].indexOf(d) < 0) - // .filter(i => i.indexOf("sipml") >= 0 ) // Uncomment when you want to test :) .filter(i => fs.statSync(path.join(definitelyTypedRoot, i)).isDirectory()) .forEach(d => { const directoryPath = path.join(definitelyTypedRoot, d); @@ -137,7 +140,7 @@ function importDefinitelyTypedTests(tscPath: string, rwcTestPath: string, defini if (testFiles.length === 0) { // no test files but multiple d.ts's, e.g. winjs - let regexp = new RegExp(d + "(([-][0-9])|([\.]d[\.]ts))"); + const regexp = new RegExp(d + "(([-][0-9])|([\.]d[\.]ts))"); if (tsFiles.length > 1 && tsFiles.every(t => filePathEndsWith(t, ".d.ts") && regexp.test(t))) { for (const fileName of tsFiles) { importDefinitelyTypedTest(tscPath, rwcTestPath, path.basename(fileName, ".d.ts"), [fileName], paramFile);