From 8d44e48dd0f63a2f48bd5045d4833e709c299a3b Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 22 Aug 2017 15:39:10 -0700 Subject: [PATCH] Fix instrumenter target + deprecation warning (#17973) --- Gulpfile.ts | 6 +++--- Jakefile.js | 2 +- src/harness/instrumenter.ts | 8 +++++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Gulpfile.ts b/Gulpfile.ts index 645443370eb..4a03557270f 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -978,7 +978,7 @@ const instrumenterPath = path.join(harnessDirectory, "instrumenter.ts"); const instrumenterJsPath = path.join(builtLocalDirectory, "instrumenter.js"); gulp.task(instrumenterJsPath, /*help*/ false, [servicesFile], () => { const settings: tsc.Settings = getCompilerSettings({ - outFile: instrumenterJsPath, + module: "commonjs", target: "es5", lib: [ "es6", @@ -990,8 +990,8 @@ gulp.task(instrumenterJsPath, /*help*/ false, [servicesFile], () => { .pipe(newer(instrumenterJsPath)) .pipe(sourcemaps.init()) .pipe(tsc(settings)) - .pipe(sourcemaps.write(".")) - .pipe(gulp.dest(".")); + .pipe(sourcemaps.write(builtLocalDirectory)) + .pipe(gulp.dest(builtLocalDirectory)); }); gulp.task("tsc-instrumented", "Builds an instrumented tsc.js", ["local", loggedIOJsPath, instrumenterJsPath, servicesFile], (done) => { diff --git a/Jakefile.js b/Jakefile.js index 546727db4e0..5ae887ee238 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -1098,7 +1098,7 @@ file(loggedIOJsPath, [builtLocalDirectory, loggedIOpath], function () { var instrumenterPath = harnessDirectory + 'instrumenter.ts'; var instrumenterJsPath = builtLocalDirectory + 'instrumenter.js'; -compileFile(instrumenterJsPath, [instrumenterPath], [tscFile, instrumenterPath].concat(libraryTargets), [], /*useBuiltCompiler*/ true, { lib: "es6", types: ["node"] }); +compileFile(instrumenterJsPath, [instrumenterPath], [tscFile, instrumenterPath].concat(libraryTargets), [], /*useBuiltCompiler*/ true, { lib: "es6", types: ["node"], noOutFile: true, outDir: builtLocalDirectory }); desc("Builds an instrumented tsc.js"); task('tsc-instrumented', [loggedIOJsPath, instrumenterJsPath, tscFile], function () { diff --git a/src/harness/instrumenter.ts b/src/harness/instrumenter.ts index 02aba0e7661..cb11be5c745 100644 --- a/src/harness/instrumenter.ts +++ b/src/harness/instrumenter.ts @@ -1,5 +1,5 @@ -const fs: any = require("fs"); -const path: any = require("path"); +import fs = require("fs"); +import path = require("path"); function instrumentForRecording(fn: string, tscPath: string) { instrument(tscPath, ` @@ -38,7 +38,9 @@ function instrument(tscPath: string, prepareCode: string, cleanupCode = "") { const index2 = index1 + invocationLine.length; const newContent = tscContent.substr(0, index1) + loggerContent + prepareCode + invocationLine + cleanupCode + tscContent.substr(index2) + "\r\n"; - fs.writeFile(tscPath, newContent); + fs.writeFile(tscPath, newContent, err => { + if (err) throw err; + }); }); }); });