@stryke/fs 0.32.8 → 0.32.10
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 +18 -23
- package/dist/copy-file.mjs +1 -1
- package/package.json +3 -3
package/dist/copy-file.cjs
CHANGED
|
@@ -7,7 +7,6 @@ exports.copyFile = copyFile;
|
|
|
7
7
|
exports.copyFileSync = copyFileSync;
|
|
8
8
|
exports.copyFiles = copyFiles;
|
|
9
9
|
exports.copyFilesSync = copyFilesSync;
|
|
10
|
-
var _path = require("@stryke/path");
|
|
11
10
|
var _correctPath = require("@stryke/path/correct-path");
|
|
12
11
|
var _filePathFns = require("@stryke/path/file-path-fns");
|
|
13
12
|
var _join = require("@stryke/path/join");
|
|
@@ -21,33 +20,29 @@ var _exists = require("./exists.cjs");
|
|
|
21
20
|
var _helpers = require("./helpers.cjs");
|
|
22
21
|
var _isFile = require("./is-file.cjs");
|
|
23
22
|
var _listFiles = require("./list-files.cjs");
|
|
24
|
-
async function copyFile(
|
|
25
|
-
const i =
|
|
26
|
-
t =
|
|
23
|
+
async function copyFile(r, o) {
|
|
24
|
+
const i = r instanceof URL ? (0, _mlly.fileURLToPath)(r) : r,
|
|
25
|
+
t = o instanceof URL ? (0, _mlly.fileURLToPath)(o) : o;
|
|
27
26
|
if ((0, _filePathFns.hasFileExtension)(t) ? (0, _exists.existsSync)((0, _filePathFns.findFilePath)(t)) || (await (0, _helpers.createDirectory)((0, _filePathFns.findFilePath)(t))) : (0, _exists.existsSync)((0, _resolveParentPath.resolveParentPath)(t)) || (await (0, _helpers.createDirectory)((0, _resolveParentPath.resolveParentPath)(t))), (0, _typeChecks.isString)(i) && (0, _exists.existsSync)(i)) return (0, _promises.copyFile)(i, t);
|
|
28
27
|
}
|
|
29
|
-
function copyFileSync(
|
|
30
|
-
const i =
|
|
31
|
-
t =
|
|
28
|
+
function copyFileSync(r, o) {
|
|
29
|
+
const i = r instanceof URL ? (0, _mlly.fileURLToPath)(r) : r,
|
|
30
|
+
t = o instanceof URL ? (0, _mlly.fileURLToPath)(o) : o;
|
|
32
31
|
if ((0, _filePathFns.hasFileExtension)(t) ? (0, _exists.existsSync)((0, _filePathFns.findFilePath)(t)) || (0, _helpers.createDirectorySync)((0, _filePathFns.findFilePath)(t)) : (0, _exists.existsSync)((0, _resolveParentPath.resolveParentPath)(t)) || (0, _helpers.createDirectorySync)((0, _resolveParentPath.resolveParentPath)(t)), (0, _typeChecks.isString)(i) && (0, _exists.existsSync)(i)) return (0, _nodeFs.copyFileSync)(i, t);
|
|
33
32
|
}
|
|
34
|
-
async function copyFiles(
|
|
35
|
-
const i =
|
|
36
|
-
t =
|
|
37
|
-
return (0, _typeChecks.isString)(i) && (0, _isFile.isFile)(i) ? copyFile(i, t) : Promise.all((await (0, _listFiles.listFiles)(i)).map(async
|
|
38
|
-
|
|
39
|
-
(0,
|
|
40
|
-
const a = (0, _join.joinPaths)(t, (0, _replace.replacePath)(r, f));
|
|
41
|
-
(0, _isFile.isDirectory)(r) ? await copyFiles(r, a) : await copyFile(r, a);
|
|
33
|
+
async function copyFiles(r, o) {
|
|
34
|
+
const i = r instanceof URL ? (0, _mlly.fileURLToPath)(r) : r,
|
|
35
|
+
t = o instanceof URL ? (0, _mlly.fileURLToPath)(o) : o;
|
|
36
|
+
return (0, _typeChecks.isString)(i) && (0, _isFile.isFile)(i) ? copyFile(i, t) : Promise.all((await (0, _listFiles.listFiles)(i)).map(async s => {
|
|
37
|
+
const c = (0, _join.joinPaths)(t, (0, _replace.replacePath)(s, (0, _typeChecks.isString)(i) ? (0, _correctPath.stripStars)(i) : i.input));
|
|
38
|
+
(0, _isFile.isDirectory)(s) ? await copyFiles(s, c) : await copyFile(s, c);
|
|
42
39
|
}));
|
|
43
40
|
}
|
|
44
|
-
function copyFilesSync(
|
|
45
|
-
const i =
|
|
46
|
-
t =
|
|
47
|
-
return (0, _typeChecks.isString)(i) && (0, _isFile.isFile)(i) ? copyFileSync(i, t) : (0, _listFiles.listFilesSync)(i).map(
|
|
48
|
-
|
|
49
|
-
(0,
|
|
50
|
-
const a = (0, _join.joinPaths)(t, (0, _replace.replacePath)(r, f));
|
|
51
|
-
(0, _isFile.isDirectory)(r) ? copyFilesSync(r, a) : copyFileSync(r, a);
|
|
41
|
+
function copyFilesSync(r, o) {
|
|
42
|
+
const i = r instanceof URL ? (0, _mlly.fileURLToPath)(r) : r,
|
|
43
|
+
t = o instanceof URL ? (0, _mlly.fileURLToPath)(o) : o;
|
|
44
|
+
return (0, _typeChecks.isString)(i) && (0, _isFile.isFile)(i) ? copyFileSync(i, t) : (0, _listFiles.listFilesSync)(i).map(s => {
|
|
45
|
+
const c = (0, _join.joinPaths)(t, (0, _replace.replacePath)(s, (0, _typeChecks.isString)(i) ? (0, _correctPath.stripStars)(i) : i.input));
|
|
46
|
+
(0, _isFile.isDirectory)(s) ? copyFilesSync(s, c) : copyFileSync(s, c);
|
|
52
47
|
});
|
|
53
48
|
}
|
package/dist/copy-file.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{stripStars as l}from"@stryke/path/correct-path";import{findFilePath as p,hasFileExtension as a}from"@stryke/path/file-path-fns";import{joinPaths as L}from"@stryke/path/join";import{replacePath as R}from"@stryke/path/replace";import{resolveParentPath as m}from"@stryke/path/resolve-parent-path";import{isString as n}from"@stryke/type-checks";import{fileURLToPath as e}from"mlly";import{copyFileSync as S}from"node:fs";import{copyFile as u}from"node:fs/promises";import{existsSync as f}from"./exists";import{createDirectory as U,createDirectorySync as y}from"./helpers";import{isDirectory as F,isFile as g}from"./is-file";import{listFiles as x,listFilesSync as w}from"./list-files";export async function copyFile(r,o){const i=r instanceof URL?e(r):r,t=o instanceof URL?e(o):o;if(a(t)?f(p(t))||await U(p(t)):f(m(t))||await U(m(t)),n(i)&&f(i))return u(i,t)}export function copyFileSync(r,o){const i=r instanceof URL?e(r):r,t=o instanceof URL?e(o):o;if(a(t)?f(p(t))||y(p(t)):f(m(t))||y(m(t)),n(i)&&f(i))return S(i,t)}export async function copyFiles(r,o){const i=r instanceof URL?e(r):r,t=o instanceof URL?e(o):o;return n(i)&&g(i)?copyFile(i,t):Promise.all((await x(i)).map(async s=>{const c=L(t,R(s,n(i)?l(i):i.input));F(s)?await copyFiles(s,c):await copyFile(s,c)}))}export function copyFilesSync(r,o){const i=r instanceof URL?e(r):r,t=o instanceof URL?e(o):o;return n(i)&&g(i)?copyFileSync(i,t):w(i).map(s=>{const c=L(t,R(s,n(i)?l(i):i.input));F(s)?copyFilesSync(s,c):copyFileSync(s,c)})}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stryke/fs",
|
|
3
|
-
"version": "0.32.
|
|
3
|
+
"version": "0.32.10",
|
|
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": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"@ltd/j-toml": "^1.38.0",
|
|
17
17
|
"@storm-software/config-tools": "^1.188.14",
|
|
18
18
|
"@stryke/convert": "^0.6.0",
|
|
19
|
-
"@stryke/path": "^0.18.
|
|
19
|
+
"@stryke/path": "^0.18.5",
|
|
20
20
|
"@stryke/string-format": "^0.12.0",
|
|
21
21
|
"chalk": "^5.6.2",
|
|
22
22
|
"defu": "^6.1.4",
|
|
@@ -409,5 +409,5 @@
|
|
|
409
409
|
"main": "./dist/index.cjs",
|
|
410
410
|
"module": "./dist/index.mjs",
|
|
411
411
|
"types": "./dist/index.d.ts",
|
|
412
|
-
"gitHead": "
|
|
412
|
+
"gitHead": "a51a5a0e2f8f4053134b6c3b30ce3d7b39075f11"
|
|
413
413
|
}
|