summaryrefslogtreecommitdiff
path: root/runtime/js
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-03-05 18:18:13 -0400
committerGitHub <noreply@github.com>2023-03-05 22:18:13 +0000
commit5f34c9be91a42e9087536d63b7e319439ceba756 (patch)
tree529a4414ef89104fa39ab422181028670f6f718b /runtime/js
parent273777f7d9201de92b6f8c6f2f9579321165ec17 (diff)
refactor: move definition of Deno.build from "runtime" to "core" (#18036)
We use information about build in several extension crates like "ext/node" or "runtime/". In an effort to move "fs" APIs to a separate crate it is a prerequisite to have this information available outside of the "runtime/" crate. This commit moves definition of "build" object to "Deno.core" that is later forwarded to "Deno.build".
Diffstat (limited to 'runtime/js')
-rw-r--r--runtime/js/01_build.js28
-rw-r--r--runtime/js/06_util.js4
-rw-r--r--runtime/js/30_fs.js3
-rw-r--r--runtime/js/90_deno_ns.js3
-rw-r--r--runtime/js/99_main.js3
5 files changed, 5 insertions, 36 deletions
diff --git a/runtime/js/01_build.js b/runtime/js/01_build.js
deleted file mode 100644
index a9515c5b8..000000000
--- a/runtime/js/01_build.js
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
-
-const primordials = globalThis.__bootstrap.primordials;
-const { ObjectFreeze, StringPrototypeSplit } = primordials;
-
-const build = {
- target: "unknown",
- arch: "unknown",
- os: "unknown",
- vendor: "unknown",
- env: undefined,
-};
-
-function setBuildInfo(target) {
- const { 0: arch, 1: vendor, 2: os, 3: env } = StringPrototypeSplit(
- target,
- "-",
- 4,
- );
- build.target = target;
- build.arch = arch;
- build.vendor = vendor;
- build.os = os;
- build.env = env;
- ObjectFreeze(build);
-}
-
-export { build, setBuildInfo };
diff --git a/runtime/js/06_util.js b/runtime/js/06_util.js
index d3c95edba..fc134d52d 100644
--- a/runtime/js/06_util.js
+++ b/runtime/js/06_util.js
@@ -1,5 +1,6 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+const core = globalThis.Deno.core;
const internals = globalThis.__bootstrap.internals;
const primordials = globalThis.__bootstrap.primordials;
const {
@@ -11,7 +12,6 @@ const {
StringPrototypeReplace,
TypeError,
} = primordials;
-import { build } from "internal:runtime/01_build.js";
import { URLPrototype } from "internal:deno_url/00_url.js";
let logDebug = false;
let logSource = "JS";
@@ -94,7 +94,7 @@ function pathFromURL(pathOrUrl) {
throw new TypeError("Must be a file URL.");
}
- return build.os == "windows"
+ return core.build.os == "windows"
? pathFromURLWin32(pathOrUrl)
: pathFromURLPosix(pathOrUrl);
}
diff --git a/runtime/js/30_fs.js b/runtime/js/30_fs.js
index a7936085e..fc0bbdca5 100644
--- a/runtime/js/30_fs.js
+++ b/runtime/js/30_fs.js
@@ -25,7 +25,6 @@ import {
writableStreamForRid,
} from "internal:deno_web/06_streams.js";
import { pathFromURL } from "internal:runtime/06_util.js";
-import { build } from "internal:runtime/01_build.js";
function chmodSync(path, mode) {
ops.op_chmod_sync(pathFromURL(path), mode);
@@ -272,7 +271,7 @@ const { 0: statStruct, 1: statBuf } = createByteStruct({
});
function parseFileInfo(response) {
- const unix = build.os === "darwin" || build.os === "linux";
+ const unix = core.build.os === "darwin" || core.build.os === "linux";
return {
isFile: response.isFile,
isDirectory: response.isDirectory,
diff --git a/runtime/js/90_deno_ns.js b/runtime/js/90_deno_ns.js
index f83695952..45db05292 100644
--- a/runtime/js/90_deno_ns.js
+++ b/runtime/js/90_deno_ns.js
@@ -10,7 +10,6 @@ import * as net from "internal:deno_net/01_net.js";
import * as tls from "internal:deno_net/02_tls.js";
import * as http from "internal:deno_http/01_http.js";
import * as flash from "internal:deno_flash/01_http.js";
-import * as build from "internal:runtime/01_build.js";
import * as errors from "internal:runtime/01_errors.js";
import * as version from "internal:runtime/01_version.ts";
import * as permissions from "internal:runtime/10_permissions.js";
@@ -65,7 +64,7 @@ const denoNs = {
renameSync: fs.renameSync,
rename: fs.rename,
version: version.version,
- build: build.build,
+ build: core.build,
statSync: fs.statSync,
lstatSync: fs.lstatSync,
stat: fs.stat,
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js
index 58465f3a2..0199c5148 100644
--- a/runtime/js/99_main.js
+++ b/runtime/js/99_main.js
@@ -42,7 +42,6 @@ const {
import * as util from "internal:runtime/06_util.js";
import * as event from "internal:deno_web/02_event.js";
import * as location from "internal:deno_web/12_location.js";
-import * as build from "internal:runtime/01_build.js";
import * as version from "internal:runtime/01_version.ts";
import * as os from "internal:runtime/30_os.js";
import * as timers from "internal:deno_web/02_timers.js";
@@ -305,7 +304,7 @@ function runtimeStart(runtimeOptions, source) {
runtimeOptions.v8Version,
runtimeOptions.tsVersion,
);
- build.setBuildInfo(runtimeOptions.target);
+ core.setBuildInfo(runtimeOptions.target);
util.setLogDebug(runtimeOptions.debugFlag, source);
colors.setNoColor(runtimeOptions.noColor || !runtimeOptions.isTty);
// deno-lint-ignore prefer-primordials