summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/_fs
diff options
context:
space:
mode:
authorKenta Moriuchi <moriken@kimamass.com>2024-01-11 07:37:25 +0900
committerGitHub <noreply@github.com>2024-01-10 15:37:25 -0700
commit515a34b4de222e35c7ade1b92614d746e73d4c2e (patch)
tree8284201fc826a33f12597959a8a8be14e0f524bd /ext/node/polyfills/_fs
parentd4893eb51a01c5a692d8ca74a3b8ff95c5fd1d9f (diff)
refactor: use `core.ensureFastOps()` (#21888)
Diffstat (limited to 'ext/node/polyfills/_fs')
-rw-r--r--ext/node/polyfills/_fs/_fs_cp.js12
-rw-r--r--ext/node/polyfills/_fs/_fs_exists.ts9
2 files changed, 14 insertions, 7 deletions
diff --git a/ext/node/polyfills/_fs/_fs_cp.js b/ext/node/polyfills/_fs/_fs_cp.js
index 245e3c76b..283b4f542 100644
--- a/ext/node/polyfills/_fs/_fs_cp.js
+++ b/ext/node/polyfills/_fs/_fs_cp.js
@@ -2,22 +2,24 @@
// deno-lint-ignore-file prefer-primordials
+import { core } from "ext:core/mod.js";
+const {
+ op_node_cp,
+ op_node_cp_sync,
+} = core.ensureFastOps();
+
import {
getValidatedPath,
validateCpOptions,
} from "ext:deno_node/internal/fs/utils.mjs";
import { promisify } from "ext:deno_node/internal/util.mjs";
-const core = globalThis.__bootstrap.core;
-const ops = core.ops;
-const { op_node_cp } = core.ensureFastOps();
-
export function cpSync(src, dest, options) {
validateCpOptions(options);
const srcPath = getValidatedPath(src, "src");
const destPath = getValidatedPath(dest, "dest");
- ops.op_node_cp_sync(srcPath, destPath);
+ op_node_cp_sync(srcPath, destPath);
}
export function cp(src, dest, options, callback) {
diff --git a/ext/node/polyfills/_fs/_fs_exists.ts b/ext/node/polyfills/_fs/_fs_exists.ts
index f930013fe..3c22fc5b8 100644
--- a/ext/node/polyfills/_fs/_fs_exists.ts
+++ b/ext/node/polyfills/_fs/_fs_exists.ts
@@ -2,7 +2,12 @@
// TODO(petamoriken): enable prefer-primordials for node polyfills
// deno-lint-ignore-file prefer-primordials
-const core = globalThis.__bootstrap.core;
+
+import { core } from "ext:core/mod.js";
+const {
+ op_node_fs_exists_sync,
+} = core.ensureFastOps();
+
import { pathFromURL } from "ext:deno_web/00_infra.js";
type ExistsCallback = (exists: boolean) => void;
@@ -35,5 +40,5 @@ Object.defineProperty(exists, kCustomPromisifiedSymbol, {
*/
export function existsSync(path: string | URL): boolean {
path = path instanceof URL ? pathFromURL(path) : path;
- return core.ops.op_node_fs_exists_sync(path);
+ return op_node_fs_exists_sync(path);
}