@stryke/fs 0.31.1 → 0.31.3
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 +21 -20
- package/dist/copy-file.d.ts +2 -2
- package/dist/copy-file.mjs +1 -1
- package/package.json +2 -2
package/dist/copy-file.cjs
CHANGED
|
@@ -8,6 +8,7 @@ exports.copyFileSync = copyFileSync;
|
|
|
8
8
|
exports.copyFiles = copyFiles;
|
|
9
9
|
exports.copyFilesSync = copyFilesSync;
|
|
10
10
|
var _filePathFns = require("@stryke/path/file-path-fns");
|
|
11
|
+
var _getParentPath = require("@stryke/path/get-parent-path");
|
|
11
12
|
var _join = require("@stryke/path/join");
|
|
12
13
|
var _replace = require("@stryke/path/replace");
|
|
13
14
|
var _typeChecks = require("@stryke/type-checks");
|
|
@@ -18,29 +19,29 @@ var _exists = require("./exists.cjs");
|
|
|
18
19
|
var _helpers = require("./helpers.cjs");
|
|
19
20
|
var _isFile = require("./is-file.cjs");
|
|
20
21
|
var _listFiles = require("./list-files.cjs");
|
|
21
|
-
async function copyFile(
|
|
22
|
-
const i =
|
|
23
|
-
|
|
24
|
-
if ((0, _exists.existsSync)((0, _filePathFns.findFilePath)(
|
|
22
|
+
async function copyFile(r, o) {
|
|
23
|
+
const i = r instanceof URL ? (0, _mlly.fileURLToPath)(r) : r,
|
|
24
|
+
t = o instanceof URL ? (0, _mlly.fileURLToPath)(o) : o;
|
|
25
|
+
if ((0, _isFile.isFile)(i) && !(0, _filePathFns.hasFileExtension)(t) && (0, _filePathFns.findFileName)(i) === (0, _filePathFns.findFileName)(t) ? (0, _exists.existsSync)((0, _getParentPath.resolveParentPath)(t)) || (await (0, _helpers.createDirectory)((0, _getParentPath.resolveParentPath)(t))) : (0, _exists.existsSync)((0, _filePathFns.findFilePath)(t)) || (await (0, _helpers.createDirectory)((0, _filePathFns.findFilePath)(t))), (0, _typeChecks.isString)(i) && (0, _exists.existsSync)(i)) return (0, _promises.copyFile)(i, t);
|
|
25
26
|
}
|
|
26
|
-
function copyFileSync(
|
|
27
|
-
const i =
|
|
28
|
-
|
|
29
|
-
if ((0, _exists.existsSync)((0, _filePathFns.findFilePath)(
|
|
27
|
+
function copyFileSync(r, o) {
|
|
28
|
+
const i = r instanceof URL ? (0, _mlly.fileURLToPath)(r) : r,
|
|
29
|
+
t = o instanceof URL ? (0, _mlly.fileURLToPath)(o) : o;
|
|
30
|
+
if ((0, _isFile.isFile)(i) && !(0, _filePathFns.hasFileExtension)(t) && (0, _filePathFns.findFileName)(i) === (0, _filePathFns.findFileName)(t) ? (0, _exists.existsSync)((0, _getParentPath.resolveParentPath)(t)) || (0, _helpers.createDirectorySync)((0, _getParentPath.resolveParentPath)(t)) : (0, _exists.existsSync)((0, _filePathFns.findFilePath)(t)) || (0, _helpers.createDirectorySync)((0, _filePathFns.findFilePath)(t)), (0, _typeChecks.isString)(i) && (0, _exists.existsSync)(i)) return (0, _nodeFs.copyFileSync)(i, t);
|
|
30
31
|
}
|
|
31
|
-
async function copyFiles(
|
|
32
|
-
const i =
|
|
33
|
-
|
|
34
|
-
return (0, _typeChecks.isString)(i) && (0, _isFile.isFile)(i) ? copyFile(i,
|
|
35
|
-
const
|
|
36
|
-
(0, _isFile.isDirectory)(
|
|
32
|
+
async function copyFiles(r, o) {
|
|
33
|
+
const i = r instanceof URL ? (0, _mlly.fileURLToPath)(r) : r,
|
|
34
|
+
t = o instanceof URL ? (0, _mlly.fileURLToPath)(o) : o;
|
|
35
|
+
return (0, _typeChecks.isString)(i) && (0, _isFile.isFile)(i) ? copyFile(i, t) : Promise.all((await (0, _listFiles.listFiles)(i)).map(async s => {
|
|
36
|
+
const c = (0, _join.joinPaths)(t, (0, _replace.replacePath)(s, (0, _typeChecks.isString)(i) ? i : i.input));
|
|
37
|
+
(0, _isFile.isDirectory)(s) ? await copyFiles(s, c) : await copyFile(s, c);
|
|
37
38
|
}));
|
|
38
39
|
}
|
|
39
|
-
function copyFilesSync(
|
|
40
|
-
const i =
|
|
41
|
-
|
|
42
|
-
return (0, _typeChecks.isString)(i) && (0, _isFile.isFile)(i) ? copyFileSync(i,
|
|
43
|
-
const
|
|
44
|
-
(0, _isFile.isDirectory)(
|
|
40
|
+
function copyFilesSync(r, o) {
|
|
41
|
+
const i = r instanceof URL ? (0, _mlly.fileURLToPath)(r) : r,
|
|
42
|
+
t = o instanceof URL ? (0, _mlly.fileURLToPath)(o) : o;
|
|
43
|
+
return (0, _typeChecks.isString)(i) && (0, _isFile.isFile)(i) ? copyFileSync(i, t) : (0, _listFiles.listFilesSync)(i).map(s => {
|
|
44
|
+
const c = (0, _join.joinPaths)(t, (0, _replace.replacePath)(s, (0, _typeChecks.isString)(i) ? i : i.input));
|
|
45
|
+
(0, _isFile.isDirectory)(s) ? copyFilesSync(s, c) : copyFileSync(s, c);
|
|
45
46
|
});
|
|
46
47
|
}
|
package/dist/copy-file.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { AssetGlob } from "@stryke/types/file";
|
|
|
6
6
|
* @param destination - The destination location
|
|
7
7
|
* @returns An indicator specifying if the copy was successful
|
|
8
8
|
*/
|
|
9
|
-
export declare function copyFile(source: string | URL
|
|
9
|
+
export declare function copyFile(source: string | URL, destination: string | URL): Promise<void>;
|
|
10
10
|
/**
|
|
11
11
|
* Synchronously copy a file from one location to another
|
|
12
12
|
*
|
|
@@ -14,7 +14,7 @@ export declare function copyFile(source: string | URL | AssetGlob, destination:
|
|
|
14
14
|
* @param destination - The destination location
|
|
15
15
|
* @returns An indicator specifying if the copy was successful
|
|
16
16
|
*/
|
|
17
|
-
export declare function copyFileSync(source: string | URL
|
|
17
|
+
export declare function copyFileSync(source: string | URL, destination: string | URL): void;
|
|
18
18
|
/**
|
|
19
19
|
* Copy files from one location to another
|
|
20
20
|
*
|
package/dist/copy-file.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{findFilePath as
|
|
1
|
+
import{findFileName as p,findFilePath as m,hasFileExtension as L}from"@stryke/path/file-path-fns";import{resolveParentPath as l}from"@stryke/path/get-parent-path";import{joinPaths as R}from"@stryke/path/join";import{replacePath as U}from"@stryke/path/replace";import{isString as n}from"@stryke/type-checks";import{fileURLToPath as e}from"mlly";import{copyFileSync as S}from"node:fs";import{copyFile as x}from"node:fs/promises";import{existsSync as f}from"./exists";import{createDirectory as y,createDirectorySync as F}from"./helpers";import{isDirectory as g,isFile as a}from"./is-file";import{listFiles as w,listFilesSync as u}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(i)&&!L(t)&&p(i)===p(t)?f(l(t))||await y(l(t)):f(m(t))||await y(m(t)),n(i)&&f(i))return x(i,t)}export function copyFileSync(r,o){const i=r instanceof URL?e(r):r,t=o instanceof URL?e(o):o;if(a(i)&&!L(t)&&p(i)===p(t)?f(l(t))||F(l(t)):f(m(t))||F(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)&&a(i)?copyFile(i,t):Promise.all((await w(i)).map(async s=>{const c=R(t,U(s,n(i)?i:i.input));g(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)&&a(i)?copyFileSync(i,t):u(i).map(s=>{const c=R(t,U(s,n(i)?i:i.input));g(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.31.
|
|
3
|
+
"version": "0.31.3",
|
|
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": "f0c288d1f905985eda0615b855597af668453273"
|
|
399
399
|
}
|