diff --git a/scripts/build/projects.js b/scripts/build/projects.js index 38db816e23b..6f3da08c86e 100644 --- a/scripts/build/projects.js +++ b/scripts/build/projects.js @@ -39,7 +39,7 @@ const execTsc = (lkg, ...args) => exec(process.execPath, [resolve(findUpRoot(), lkg ? "./lib/tsc" : "./built/local/tsc"), "-b", ...args], - { hidePrompt: true }) + { hidePrompt: true }); const projectBuilder = new ProjectQueue((projects, lkg, force) => execTsc(lkg, ...(force ? ["--force"] : []), ...projects)); diff --git a/src/harness/findUpDir.ts b/src/harness/findUpDir.ts index 03b5ebdf285..3078554f61b 100644 --- a/src/harness/findUpDir.ts +++ b/src/harness/findUpDir.ts @@ -1,11 +1,11 @@ -namespace findUpDir { - import { join, resolve, dirname } from "path"; - import { existsSync } from "fs"; +namespace Utils { + const { join, resolve, dirname } = require("path") as typeof import("path"); + const { existsSync } = require("fs") as typeof import("fs"); // search directories upward to avoid hard-wired paths based on the // build tree (same as scripts/build/findUpDir.js) - export function findUpFile(name: string) { + export function findUpFile(name: string): string { let dir = __dirname; while (true) { const fullPath = join(dir, name); diff --git a/src/harness/harnessIO.ts b/src/harness/harnessIO.ts index 08c11fecf12..bf9f45d8826 100644 --- a/src/harness/harnessIO.ts +++ b/src/harness/harnessIO.ts @@ -41,6 +41,7 @@ namespace Harness { export const virtualFileSystemRoot = "/"; function createNodeIO(): IO { + const workspaceRoot = Utils.findUpRoot(); let fs: any, pathModule: any; if (require) { fs = require("fs"); @@ -154,7 +155,7 @@ namespace Harness { log: s => console.log(s), args: () => ts.sys.args, getExecutingFilePath: () => ts.sys.getExecutingFilePath(), - getWorkspaceRoot: () => vpath.resolve(__dirname, "../.."), + getWorkspaceRoot: () => workspaceRoot, exit: exitCode => ts.sys.exit(exitCode), readDirectory: (path, extension, exclude, include, depth) => ts.sys.readDirectory(path, extension, exclude, include, depth), getAccessibleFileSystemEntries, diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index 08b9a0bc65e..37c24527730 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -28,6 +28,7 @@ "evaluatorImpl.ts", "fakesHosts.ts", "client.ts", + "findUpDir.ts", "runnerbase.ts", "sourceMapRecorder.ts", diff --git a/src/testRunner/parallel/host.ts b/src/testRunner/parallel/host.ts index 421b95ef93a..819325bc85c 100644 --- a/src/testRunner/parallel/host.ts +++ b/src/testRunner/parallel/host.ts @@ -14,7 +14,7 @@ namespace Harness.Parallel.Host { const { statSync } = require("fs") as typeof import("fs"); // NOTE: paths for module and types for FailedTestReporter _do not_ line up due to our use of --outFile for run.js - const FailedTestReporter = require(path.resolve(__dirname, "../../scripts/failed-tests")) as typeof import("../../../scripts/failed-tests"); + const FailedTestReporter = require(Utils.findUpFile("scripts/failed-tests.js")) as typeof import("../../../scripts/failed-tests"); const perfdataFileNameFragment = ".parallelperf"; const perfData = readSavedPerfData(configOption);