diff options
Diffstat (limited to 'cli/tsc/06_util.js')
-rw-r--r-- | cli/tsc/06_util.js | 101 |
1 files changed, 3 insertions, 98 deletions
diff --git a/cli/tsc/06_util.js b/cli/tsc/06_util.js index 086275bd8..b6a582f9e 100644 --- a/cli/tsc/06_util.js +++ b/cli/tsc/06_util.js @@ -1,8 +1,7 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. ((window) => { - const { build } = window.__bootstrap.build; - const internals = window.__bootstrap.internals; + const core = Deno.core; let logDebug = false; let logSource = "JS"; @@ -15,9 +14,8 @@ function log(...args) { if (logDebug) { - // if we destructure `console` off `globalThis` too early, we don't bind to - // the right console, therefore we don't log anything out. - globalThis.console.log(`DEBUG ${logSource} -`, ...args); + const stringifiedArgs = args.map(JSON.stringify).join(" "); + core.print(`DEBUG ${logSource} - ${stringifiedArgs}\n`); } } @@ -50,93 +48,6 @@ throw new Error("not implemented"); } - function immutableDefine( - o, - p, - // eslint-disable-next-line @typescript-eslint/no-explicit-any - value, - ) { - Object.defineProperty(o, p, { - value, - configurable: false, - writable: false, - }); - } - - function pathFromURLWin32(url) { - const hostname = url.hostname; - const pathname = decodeURIComponent(url.pathname.replace(/\//g, "\\")); - - if (hostname !== "") { - //TODO(actual-size) Node adds a punycode decoding step, we should consider adding this - return `\\\\${hostname}${pathname}`; - } - - const validPath = /^\\(?<driveLetter>[A-Za-z]):\\/; - const matches = validPath.exec(pathname); - - if (!matches?.groups?.driveLetter) { - throw new TypeError("A URL with the file schema must be absolute."); - } - - // we don't want a leading slash on an absolute path in Windows - return pathname.slice(1); - } - - function pathFromURLPosix(url) { - if (url.hostname !== "") { - throw new TypeError(`Host must be empty.`); - } - - return decodeURIComponent(url.pathname); - } - - function pathFromURL(pathOrUrl) { - if (pathOrUrl instanceof URL) { - if (pathOrUrl.protocol != "file:") { - throw new TypeError("Must be a file URL."); - } - - return build.os == "windows" - ? pathFromURLWin32(pathOrUrl) - : pathFromURLPosix(pathOrUrl); - } - return pathOrUrl; - } - - internals.exposeForTest("pathFromURL", pathFromURL); - - function writable(value) { - return { - value, - writable: true, - enumerable: true, - configurable: true, - }; - } - - function nonEnumerable(value) { - return { - value, - writable: true, - configurable: true, - }; - } - - function readOnly(value) { - return { - value, - enumerable: true, - }; - } - - function getterOnly(getter) { - return { - get: getter, - enumerable: true, - }; - } - window.__bootstrap.util = { log, setLogDebug, @@ -144,11 +55,5 @@ createResolvable, assert, AssertionError, - immutableDefine, - pathFromURL, - writable, - nonEnumerable, - readOnly, - getterOnly, }; })(this); |