Fix require paths in closure serialization on Windows.

We were ending up with unescaped backslashes in require paths, which was
causing the requires to fail.
This commit is contained in:
pat@pulumi.com 2017-10-27 18:41:49 -07:00
parent 8d7a87f694
commit 8fd2d3e9e0

View file

@ -2,6 +2,7 @@
import * as crypto from "crypto";
import { relative as pathRelative } from "path";
import { sep as pathSep } from "path";
import * as ts from "typescript";
import * as log from "../log";
import { debuggablePromise } from "./debuggable";
@ -245,7 +246,7 @@ function findRequirableModuleName(obj: any): string | undefined {
if (require.cache[path].exports === obj) {
// Rewrite the path to be a local module reference relative to the
// current working directory
const modPath = pathRelative(process.cwd(), path);
const modPath = pathRelative(process.cwd(), path).replace(/\\/g, "\\\\");
return "./" + modPath;
}
}