Skip to content

Commit

Permalink
Fix jake task, style/const in script.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielRosenwasser committed Sep 18, 2015
1 parent 37ee17d commit 5a2a702
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
26 changes: 17 additions & 9 deletions Jakefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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");

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 });
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 5a2a702

Please sign in to comment.