mirror of
https://github.com/denoland/deno.git
synced 2024-11-30 16:40:57 -05:00
909986fa6e
Follow up to https://github.com/denoland/deno/pull/22135
39 lines
989 B
JavaScript
39 lines
989 B
JavaScript
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
|
|
// deno-lint-ignore-file prefer-primordials
|
|
|
|
import { op_node_cp, op_node_cp_sync } from "ext:core/ops";
|
|
|
|
import {
|
|
getValidatedPath,
|
|
validateCpOptions,
|
|
} from "ext:deno_node/internal/fs/utils.mjs";
|
|
import { promisify } from "ext:deno_node/internal/util.mjs";
|
|
|
|
export function cpSync(src, dest, options) {
|
|
validateCpOptions(options);
|
|
const srcPath = getValidatedPath(src, "src");
|
|
const destPath = getValidatedPath(dest, "dest");
|
|
|
|
op_node_cp_sync(srcPath, destPath);
|
|
}
|
|
|
|
export function cp(src, dest, options, callback) {
|
|
if (typeof options === "function") {
|
|
callback = options;
|
|
options = {};
|
|
}
|
|
validateCpOptions(options);
|
|
const srcPath = getValidatedPath(src, "src");
|
|
const destPath = getValidatedPath(dest, "dest");
|
|
|
|
op_node_cp(
|
|
srcPath,
|
|
destPath,
|
|
).then(
|
|
(res) => callback(null, res),
|
|
(err) => callback(err, null),
|
|
);
|
|
}
|
|
|
|
export const cpPromise = promisify(cp);
|