@stryke/fs 0.30.0 → 0.30.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/copy-file.cjs +33 -9
- package/dist/copy-file.d.ts +12 -15
- package/dist/copy-file.mjs +1 -1
- package/package.json +2 -2
package/dist/copy-file.cjs
CHANGED
|
@@ -3,14 +3,38 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.copyFile = copyFile;
|
|
7
|
+
exports.copyFileSync = copyFileSync;
|
|
8
|
+
exports.copyFiles = copyFiles;
|
|
9
|
+
exports.copyFilesSync = copyFilesSync;
|
|
10
|
+
var _path = require("@stryke/path");
|
|
11
|
+
var _mlly = require("mlly");
|
|
7
12
|
var _nodeFs = require("node:fs");
|
|
8
13
|
var _promises = require("node:fs/promises");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
var _helpers = require("./helpers.cjs");
|
|
15
|
+
var _isFile = require("./is-file.cjs");
|
|
16
|
+
var _listFiles = require("./list-files.cjs");
|
|
17
|
+
async function copyFile(t, r) {
|
|
18
|
+
return (0, _promises.copyFile)(t, r);
|
|
19
|
+
}
|
|
20
|
+
function copyFileSync(t, r) {
|
|
21
|
+
return (0, _nodeFs.copyFileSync)(t, r);
|
|
22
|
+
}
|
|
23
|
+
async function copyFiles(t, r) {
|
|
24
|
+
const i = t instanceof URL ? (0, _mlly.fileURLToPath)(t) : t,
|
|
25
|
+
o = r instanceof URL ? (0, _mlly.fileURLToPath)(r) : r;
|
|
26
|
+
return (0, _isFile.isFile)(i) ? copyFile(i, o) : (await (0, _helpers.createDirectory)(o), Promise.all((await (0, _listFiles.listFiles)(i)).map(async n => {
|
|
27
|
+
const c = (0, _path.joinPaths)(i, n),
|
|
28
|
+
s = (0, _path.joinPaths)(o, n);
|
|
29
|
+
(0, _isFile.isDirectory)(n) ? await copyFiles(c, s) : await copyFile(c, s);
|
|
30
|
+
})));
|
|
31
|
+
}
|
|
32
|
+
function copyFilesSync(t, r) {
|
|
33
|
+
const i = t instanceof URL ? (0, _mlly.fileURLToPath)(t) : t,
|
|
34
|
+
o = r instanceof URL ? (0, _mlly.fileURLToPath)(r) : r;
|
|
35
|
+
return (0, _isFile.isFile)(i) ? copyFileSync(i, o) : ((0, _helpers.createDirectorySync)(o), (0, _listFiles.listFilesSync)(i).map(n => {
|
|
36
|
+
const c = (0, _path.joinPaths)(i, n),
|
|
37
|
+
s = (0, _path.joinPaths)(o, n);
|
|
38
|
+
(0, _isFile.isDirectory)(n) ? copyFilesSync(c, s) : copyFileSync(c, s);
|
|
39
|
+
}));
|
|
40
|
+
}
|
package/dist/copy-file.d.ts
CHANGED
|
@@ -1,35 +1,32 @@
|
|
|
1
|
-
import type { CopyOptions, CopySyncOptions } from "node:fs";
|
|
2
1
|
/**
|
|
3
2
|
* Copy a file from one location to another
|
|
4
3
|
*
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
4
|
+
* @param source - The file to copy, this can be a file, directory, URL, or glob pattern
|
|
5
|
+
* @param destination - The destination location
|
|
7
6
|
* @returns An indicator specifying if the copy was successful
|
|
8
7
|
*/
|
|
9
|
-
export declare
|
|
8
|
+
export declare function copyFile(source: string | URL, destination: string | URL): Promise<void>;
|
|
10
9
|
/**
|
|
11
10
|
* Synchronously copy a file from one location to another
|
|
12
11
|
*
|
|
13
|
-
* @param
|
|
14
|
-
* @param
|
|
12
|
+
* @param source - The file to copy, this can be a file, directory, URL, or glob pattern
|
|
13
|
+
* @param destination - The destination location
|
|
15
14
|
* @returns An indicator specifying if the copy was successful
|
|
16
15
|
*/
|
|
17
|
-
export declare
|
|
16
|
+
export declare function copyFileSync(source: string | URL, destination: string | URL): void;
|
|
18
17
|
/**
|
|
19
18
|
* Copy files from one location to another
|
|
20
19
|
*
|
|
21
|
-
* @param
|
|
22
|
-
* @param
|
|
23
|
-
* @param options - The copy options
|
|
20
|
+
* @param source - The source location, this can be a file, directory, URL, or glob pattern
|
|
21
|
+
* @param destination - The destination location
|
|
24
22
|
* @returns An indicator specifying if the copy was successful
|
|
25
23
|
*/
|
|
26
|
-
export declare
|
|
24
|
+
export declare function copyFiles(source: string | URL, destination: string | URL): Promise<void | void[]>;
|
|
27
25
|
/**
|
|
28
26
|
* Synchronously copy files from one location to another
|
|
29
27
|
*
|
|
30
|
-
* @param
|
|
31
|
-
* @param
|
|
32
|
-
* @param options - The copy options
|
|
28
|
+
* @param source - The source location, this can be a file, directory, URL, or glob pattern
|
|
29
|
+
* @param destination - The destination location
|
|
33
30
|
* @returns An indicator specifying if the copy was successful
|
|
34
31
|
*/
|
|
35
|
-
export declare
|
|
32
|
+
export declare function copyFilesSync(source: string | URL, destination: string | URL): void | void[];
|
package/dist/copy-file.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{joinPaths as e}from"@stryke/path";import{fileURLToPath as f}from"mlly";import{copyFileSync as m}from"node:fs";import{copyFile as y}from"node:fs/promises";import{createDirectory as l,createDirectorySync as L}from"./helpers";import{isDirectory as p,isFile as a}from"./is-file";import{listFiles as R,listFilesSync as U}from"./list-files";export async function copyFile(t,r){return y(t,r)}export function copyFileSync(t,r){return m(t,r)}export async function copyFiles(t,r){const i=t instanceof URL?f(t):t,o=r instanceof URL?f(r):r;return a(i)?copyFile(i,o):(await l(o),Promise.all((await R(i)).map(async n=>{const c=e(i,n),s=e(o,n);p(n)?await copyFiles(c,s):await copyFile(c,s)})))}export function copyFilesSync(t,r){const i=t instanceof URL?f(t):t,o=r instanceof URL?f(r):r;return a(i)?copyFileSync(i,o):(L(o),U(i).map(n=>{const c=e(i,n),s=e(o,n);p(n)?copyFilesSync(c,s):copyFileSync(c,s)}))}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stryke/fs",
|
|
3
|
-
"version": "0.30.
|
|
3
|
+
"version": "0.30.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing various file system utilities that expand the functionality of NodeJs's built-in `fs` module.",
|
|
6
6
|
"repository": {
|
|
@@ -395,5 +395,5 @@
|
|
|
395
395
|
"main": "./dist/index.cjs",
|
|
396
396
|
"module": "./dist/index.mjs",
|
|
397
397
|
"types": "./dist/index.d.ts",
|
|
398
|
-
"gitHead": "
|
|
398
|
+
"gitHead": "e4e84e05b3cd3c057f3817b6cc40de600caa6fe5"
|
|
399
399
|
}
|