@stryke/fs 0.28.7 → 0.30.0

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,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.copyFiles = exports.copyFile = void 0;
6
+ exports.copyFilesSync = exports.copyFiles = exports.copyFileSync = exports.copyFile = void 0;
7
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
- exports.copyFile = copyFile;
11
- exports.copyFiles = copyFiles;
8
+ var _promises = require("node:fs/promises");
9
+ const copyFile = async (n, o) => (0, _promises.copyFile)(n, o, _nodeFs.constants.COPYFILE_FICLONE),
10
+ copyFileSync = (n, o) => (0, _nodeFs.copyFileSync)(n, o, _nodeFs.constants.COPYFILE_FICLONE),
11
+ copyFiles = async (n, o, t) => (0, _promises.cp)(n, o, t),
12
+ copyFilesSync = (n, o, t) => (0, _nodeFs.cpSync)(n, o, t);
13
+ exports.copyFilesSync = copyFilesSync;
14
+ exports.copyFiles = copyFiles;
15
+ exports.copyFileSync = copyFileSync;
16
+ exports.copyFile = copyFile;
@@ -1,4 +1,20 @@
1
- import type { CopySyncOptions } from "node:fs";
1
+ import type { CopyOptions, CopySyncOptions } from "node:fs";
2
+ /**
3
+ * Copy a file from one location to another
4
+ *
5
+ * @param file - The file to copy
6
+ * @param to - The destination location
7
+ * @returns An indicator specifying if the copy was successful
8
+ */
9
+ export declare const copyFile: (file: string, to: string) => Promise<void>;
10
+ /**
11
+ * Synchronously copy a file from one location to another
12
+ *
13
+ * @param file - The file to copy
14
+ * @param to - The destination location
15
+ * @returns An indicator specifying if the copy was successful
16
+ */
17
+ export declare const copyFileSync: (file: string, to: string) => void;
2
18
  /**
3
19
  * Copy files from one location to another
4
20
  *
@@ -7,12 +23,13 @@ import type { CopySyncOptions } from "node:fs";
7
23
  * @param options - The copy options
8
24
  * @returns An indicator specifying if the copy was successful
9
25
  */
10
- export declare const copyFiles: (from: string, to: string, options?: CopySyncOptions) => void;
26
+ export declare const copyFiles: (from: string, to: string, options?: CopyOptions) => Promise<void>;
11
27
  /**
12
- * Copy a file from one location to another
28
+ * Synchronously copy files from one location to another
13
29
  *
14
- * @param file - The file to copy
30
+ * @param from - The source location
15
31
  * @param to - The destination location
32
+ * @param options - The copy options
16
33
  * @returns An indicator specifying if the copy was successful
17
34
  */
18
- export declare const copyFile: (file: string, to: string) => void;
35
+ export declare const copyFilesSync: (from: string, to: string, options?: CopySyncOptions) => 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{constants as p,copyFileSync as r,cpSync as s}from"node:fs";import{cp as c,copyFile as i}from"node:fs/promises";export const copyFile=async(n,o)=>i(n,o,p.COPYFILE_FICLONE),copyFileSync=(n,o)=>r(n,o,p.COPYFILE_FICLONE),copyFiles=async(n,o,t)=>c(n,o,t),copyFilesSync=(n,o,t)=>s(n,o,t);
@@ -5,7 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.list = list;
7
7
  exports.listDirectories = listDirectories;
8
+ exports.listDirectoriesSync = listDirectoriesSync;
8
9
  exports.listFiles = listFiles;
10
+ exports.listFilesSync = listFilesSync;
11
+ exports.listSync = listSync;
9
12
  var _defu = _interopRequireDefault(require("defu"));
10
13
  var _glob = require("glob");
11
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -15,15 +18,30 @@ const p = {
15
18
  async function list(i, t) {
16
19
  return (0, _glob.glob)(i, (0, _defu.default)(t ?? {}, p));
17
20
  }
21
+ function listSync(i, t) {
22
+ return _glob.glob.sync(i, (0, _defu.default)(t ?? {}, p));
23
+ }
18
24
  async function listFiles(i, t) {
19
25
  const s = (await list(i, (0, _defu.default)({
20
26
  withFileTypes: !0
21
27
  }, t ?? {}))).filter(e => e.isFile());
22
28
  return t?.withFileTypes ? s : s.map(e => e.fullpath());
23
29
  }
30
+ function listFilesSync(i, t) {
31
+ const s = listSync(i, (0, _defu.default)({
32
+ withFileTypes: !0
33
+ }, t ?? {})).filter(e => e.isFile());
34
+ return t?.withFileTypes ? s : s.map(e => e.fullpath());
35
+ }
24
36
  async function listDirectories(i, t) {
25
37
  const s = (await list(i, (0, _defu.default)({
26
38
  withFileTypes: !0
27
39
  }, t ?? {}))).filter(e => e.isDirectory());
28
40
  return t?.withFileTypes ? s : s.map(e => e.fullpath());
41
+ }
42
+ function listDirectoriesSync(i, t) {
43
+ const s = listSync(i, (0, _defu.default)({
44
+ withFileTypes: !0
45
+ }, t ?? {})).filter(e => e.isDirectory());
46
+ return t?.withFileTypes ? s : s.map(e => e.fullpath());
29
47
  }
@@ -8,6 +8,13 @@ export type InferListReturnType<TOptions extends GlobOptions> = TOptions["withFi
8
8
  * @returns A list of file paths
9
9
  */
10
10
  export declare function list<TOptions extends ListOptions>(filesGlob: string, options?: TOptions): Promise<InferListReturnType<TOptions>>;
11
+ /**
12
+ * A synchronous files and directories listing helper function
13
+ *
14
+ * @param filesGlob - A glob pattern to match files
15
+ * @returns A list of file paths
16
+ */
17
+ export declare function listSync<TOptions extends ListOptions>(filesGlob: string, options?: TOptions): InferListReturnType<TOptions>;
11
18
  /**
12
19
  * A file listing helper function
13
20
  *
@@ -15,6 +22,13 @@ export declare function list<TOptions extends ListOptions>(filesGlob: string, op
15
22
  * @returns A list of file paths
16
23
  */
17
24
  export declare function listFiles<TOptions extends ListOptions>(filesGlob: string, options?: TOptions): Promise<InferListReturnType<TOptions>>;
25
+ /**
26
+ * A synchronous file listing helper function
27
+ *
28
+ * @param filesGlob - A glob pattern to match files
29
+ * @returns A list of file paths
30
+ */
31
+ export declare function listFilesSync<TOptions extends ListOptions>(filesGlob: string, options?: TOptions): InferListReturnType<TOptions>;
18
32
  /**
19
33
  * A directories listing helper function
20
34
  *
@@ -22,3 +36,10 @@ export declare function listFiles<TOptions extends ListOptions>(filesGlob: strin
22
36
  * @returns A list of file paths
23
37
  */
24
38
  export declare function listDirectories<TOptions extends ListOptions>(filesGlob: string, options?: TOptions): Promise<InferListReturnType<TOptions>>;
39
+ /**
40
+ * A synchronous directories listing helper function
41
+ *
42
+ * @param filesGlob - A glob pattern to match files
43
+ * @returns A list of file paths
44
+ */
45
+ export declare function listDirectoriesSync<TOptions extends ListOptions>(filesGlob: string, options?: TOptions): InferListReturnType<TOptions>;
@@ -1 +1 @@
1
- import n from"defu";import{glob as r}from"glob";const p={dot:!0};export async function list(i,t){return r(i,n(t??{},p))}export async function listFiles(i,t){const s=(await list(i,n({withFileTypes:!0},t??{}))).filter(e=>e.isFile());return t?.withFileTypes?s:s.map(e=>e.fullpath())}export async function listDirectories(i,t){const s=(await list(i,n({withFileTypes:!0},t??{}))).filter(e=>e.isDirectory());return t?.withFileTypes?s:s.map(e=>e.fullpath())}
1
+ import n from"defu";import{glob as r}from"glob";const p={dot:!0};export async function list(i,t){return r(i,n(t??{},p))}export function listSync(i,t){return r.sync(i,n(t??{},p))}export async function listFiles(i,t){const s=(await list(i,n({withFileTypes:!0},t??{}))).filter(e=>e.isFile());return t?.withFileTypes?s:s.map(e=>e.fullpath())}export function listFilesSync(i,t){const s=listSync(i,n({withFileTypes:!0},t??{})).filter(e=>e.isFile());return t?.withFileTypes?s:s.map(e=>e.fullpath())}export async function listDirectories(i,t){const s=(await list(i,n({withFileTypes:!0},t??{}))).filter(e=>e.isDirectory());return t?.withFileTypes?s:s.map(e=>e.fullpath())}export function listDirectoriesSync(i,t){const s=listSync(i,n({withFileTypes:!0},t??{})).filter(e=>e.isDirectory());return t?.withFileTypes?s:s.map(e=>e.fullpath())}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/fs",
3
- "version": "0.28.7",
3
+ "version": "0.30.0",
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.2",
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.0"
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": "f49dba31218c591b8b0d358b6e83f09be4a2175b"
398
+ "gitHead": "897c39f136bf41e3ad49b8e8c5a6431968e0b07e"
399
399
  }