@stryke/fs 0.29.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.
@@ -3,9 +3,38 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.copyFiles = exports.copyFile = void 0;
7
- var _nodeFs = require("node:fs");
8
- const copyFiles = (n, o, t) => (0, _nodeFs.cpSync)(n, o, t),
9
- copyFile = (n, o) => (0, _nodeFs.copyFileSync)(n, o, _nodeFs.constants.COPYFILE_FICLONE);
10
6
  exports.copyFile = copyFile;
11
- exports.copyFiles = copyFiles;
7
+ exports.copyFileSync = copyFileSync;
8
+ exports.copyFiles = copyFiles;
9
+ exports.copyFilesSync = copyFilesSync;
10
+ var _path = require("@stryke/path");
11
+ var _mlly = require("mlly");
12
+ var _nodeFs = require("node:fs");
13
+ var _promises = require("node:fs/promises");
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
+ }
@@ -1,18 +1,32 @@
1
- import type { CopySyncOptions } from "node:fs";
1
+ /**
2
+ * Copy a file from one location to another
3
+ *
4
+ * @param source - The file to copy, this can be a file, directory, URL, or glob pattern
5
+ * @param destination - The destination location
6
+ * @returns An indicator specifying if the copy was successful
7
+ */
8
+ export declare function copyFile(source: string | URL, destination: string | URL): Promise<void>;
9
+ /**
10
+ * Synchronously copy a file from one location to another
11
+ *
12
+ * @param source - The file to copy, this can be a file, directory, URL, or glob pattern
13
+ * @param destination - The destination location
14
+ * @returns An indicator specifying if the copy was successful
15
+ */
16
+ export declare function copyFileSync(source: string | URL, destination: string | URL): void;
2
17
  /**
3
18
  * Copy files from one location to another
4
19
  *
5
- * @param from - The source location
6
- * @param to - The destination location
7
- * @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
8
22
  * @returns An indicator specifying if the copy was successful
9
23
  */
10
- export declare const copyFiles: (from: string, to: string, options?: CopySyncOptions) => void;
24
+ export declare function copyFiles(source: string | URL, destination: string | URL): Promise<void | void[]>;
11
25
  /**
12
- * Copy a file from one location to another
26
+ * Synchronously copy files from one location to another
13
27
  *
14
- * @param file - The file to copy
15
- * @param to - The destination location
28
+ * @param source - The source location, this can be a file, directory, URL, or glob pattern
29
+ * @param destination - The destination location
16
30
  * @returns An indicator specifying if the copy was successful
17
31
  */
18
- export declare const copyFile: (file: string, to: string) => void;
32
+ export declare function copyFilesSync(source: string | URL, destination: string | URL): void | void[];
@@ -1 +1 @@
1
- import{constants as r,copyFileSync as p,cpSync as s}from"node:fs";export const copyFiles=(n,o,t)=>s(n,o,t),copyFile=(n,o)=>p(n,o,r.COPYFILE_FICLONE);
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.29.0",
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": {
@@ -16,7 +16,7 @@
16
16
  "@ltd/j-toml": "^1.38.0",
17
17
  "@storm-software/config-tools": "latest",
18
18
  "@stryke/convert": "^0.6.0",
19
- "@stryke/path": "^0.15.3",
19
+ "@stryke/path": "^0.15.4",
20
20
  "@stryke/string-format": "^0.12.0",
21
21
  "chalk": "^5.4.1",
22
22
  "defu": "^6.1.4",
@@ -27,7 +27,7 @@
27
27
  "yaml": "^2.8.1",
28
28
  "@stryke/json": "^0.9.3",
29
29
  "@stryke/type-checks": "^0.3.10",
30
- "@stryke/types": "^0.9.1"
30
+ "@stryke/types": "^0.9.2"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/node": "^22.14.0",
@@ -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": "de2c2a0130fd7d91ac5e94b47ee1addd8dd09a65"
398
+ "gitHead": "e4e84e05b3cd3c057f3817b6cc40de600caa6fe5"
399
399
  }