@reliverse/relifso 1.2.4 → 1.2.5

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.
@@ -1,2 +1,6 @@
1
- export declare function mkdirsSync(dir: string): string | undefined;
2
- export declare function mkdirs(dir: string): Promise<string | undefined>;
1
+ export interface MakeDirectoryOptions {
2
+ recursive?: boolean;
3
+ mode?: number | string;
4
+ }
5
+ export declare function mkdirsSync(dir: string, options?: MakeDirectoryOptions): string | undefined;
6
+ export declare function mkdirs(dir: string, options?: MakeDirectoryOptions): Promise<string | undefined>;
@@ -1,19 +1,21 @@
1
1
  import { mkdirSync, existsSync } from "node:fs";
2
2
  import { mkdir, stat } from "node:fs/promises";
3
- export function mkdirsSync(dir) {
3
+ export function mkdirsSync(dir, options) {
4
4
  if (existsSync(dir)) {
5
5
  return;
6
6
  }
7
- return mkdirSync(dir, { recursive: true });
7
+ return mkdirSync(dir, { recursive: true, mode: options?.mode });
8
8
  }
9
- export async function mkdirs(dir) {
9
+ export async function mkdirs(dir, options) {
10
10
  try {
11
- await stat(dir);
12
- return void 0;
11
+ const dirStat = await stat(dir);
12
+ if (dirStat.isDirectory()) {
13
+ return void 0;
14
+ }
13
15
  } catch (error) {
14
- if (error.code === "ENOENT") {
15
- return mkdir(dir, { recursive: true });
16
+ if (error.code !== "ENOENT") {
17
+ throw error;
16
18
  }
17
- throw error;
18
19
  }
20
+ return mkdir(dir, { recursive: true, mode: options?.mode });
19
21
  }
package/bin/mod.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { Stats } from "node:fs";
2
- import { accessSync, constants, readdirSync, statSync } from "node:fs";
3
- import { readdir as nodeReaddirInternal, stat as nodeStatInternal, readdir, stat, access } from "node:fs/promises";
2
+ import { accessSync, constants, readdirSync, statSync, copyFileSync } from "node:fs";
3
+ import { readdir as nodeReaddirInternal, stat as nodeStatInternal, readdir, stat, access, copyFile } from "node:fs/promises";
4
4
  import type { DiveOptions } from "./impl/dive.js";
5
5
  import { copy, copySync } from "./impl/copy.js";
6
6
  import { createFile, createFileSync } from "./impl/create-file.js";
@@ -40,7 +40,7 @@ export type { ReadFileOptions } from "./impl/read-file.js";
40
40
  export type { ReadJsonOptions } from "./impl/read-json.js";
41
41
  export type { JsonStringifyOptions } from "./impl/write-json.js";
42
42
  export type { WriteJsonOptions } from "./impl/write-json.js";
43
- export { readJson, writeJson, createFile, writeFile, readFile, mkdirs, emptyDir, pathExists, copy, move, remove, readdir, stat, access, readJsonSync, writeJsonSync, createFileSync, writeFileSync, readFileSync, mkdirsSync, emptyDirSync, pathExistsSync, copySync, moveSync, removeSync, readdirSync, statSync, accessSync, constants, mkdirp, mkdirpSync, rimraf, rimrafSync, ncp, ncpSync, ensureDir, ensureDirSync, ensureFile, ensureFileSync, outputJson, outputJsonSync, outputFile, outputFileSync, diveSync, mkdir, mkdirSync, unlink, unlinkSync, rename, renameSync, };
43
+ export { readJson, writeJson, createFile, writeFile, readFile, mkdirs, emptyDir, pathExists, copy, move, remove, readdir, stat, access, copyFile, readJsonSync, writeJsonSync, createFileSync, writeFileSync, readFileSync, mkdirsSync, emptyDirSync, pathExistsSync, copySync, moveSync, removeSync, readdirSync, statSync, accessSync, constants, copyFileSync, mkdirp, mkdirpSync, rimraf, rimrafSync, ncp, ncpSync, ensureDir, ensureDirSync, ensureFile, ensureFileSync, outputJson, outputJsonSync, outputFile, outputFileSync, diveSync, mkdir, mkdirSync, unlink, unlinkSync, rename, renameSync, };
44
44
  declare const fs: {
45
45
  readJson: typeof readJson;
46
46
  writeJson: typeof writeJson;
@@ -56,6 +56,7 @@ declare const fs: {
56
56
  readdir: typeof nodeReaddirInternal;
57
57
  stat: typeof nodeStatInternal;
58
58
  access: typeof access;
59
+ copyFile: typeof copyFile;
59
60
  readJsonSync: typeof readJsonSync;
60
61
  writeJsonSync: typeof writeJsonSync;
61
62
  createFileSync: typeof createFileSync;
@@ -71,6 +72,7 @@ declare const fs: {
71
72
  statSync: import("fs").StatSyncFn;
72
73
  accessSync: typeof accessSync;
73
74
  constants: typeof constants;
75
+ copyFileSync: typeof copyFileSync;
74
76
  mkdirp: typeof mkdirs;
75
77
  mkdirpSync: typeof mkdirsSync;
76
78
  rimraf: typeof remove;
package/bin/mod.js CHANGED
@@ -1,5 +1,12 @@
1
- import { accessSync, constants, readdirSync, statSync } from "node:fs";
2
- import { readdir as nodeReaddirInternal, stat as nodeStatInternal, readdir, stat, access } from "node:fs/promises";
1
+ import { accessSync, constants, readdirSync, statSync, copyFileSync } from "node:fs";
2
+ import {
3
+ readdir as nodeReaddirInternal,
4
+ stat as nodeStatInternal,
5
+ readdir,
6
+ stat,
7
+ access,
8
+ copyFile
9
+ } from "node:fs/promises";
3
10
  import { join as pathJoin } from "node:path";
4
11
  import { copy, copySync } from "./impl/copy.js";
5
12
  import { createFile, createFileSync } from "./impl/create-file.js";
@@ -123,6 +130,7 @@ export {
123
130
  readdir,
124
131
  stat,
125
132
  access,
133
+ copyFile,
126
134
  readJsonSync,
127
135
  writeJsonSync,
128
136
  createFileSync,
@@ -138,6 +146,7 @@ export {
138
146
  statSync,
139
147
  accessSync,
140
148
  constants,
149
+ copyFileSync,
141
150
  mkdirp,
142
151
  mkdirpSync,
143
152
  rimraf,
@@ -176,6 +185,7 @@ const fs = {
176
185
  readdir,
177
186
  stat,
178
187
  access,
188
+ copyFile,
179
189
  // sync methods
180
190
  readJsonSync,
181
191
  writeJsonSync,
@@ -192,6 +202,7 @@ const fs = {
192
202
  statSync,
193
203
  accessSync,
194
204
  constants,
205
+ copyFileSync,
195
206
  // alias
196
207
  mkdirp,
197
208
  mkdirpSync,
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "license": "MIT",
6
6
  "name": "@reliverse/relifso",
7
7
  "type": "module",
8
- "version": "1.2.4",
8
+ "version": "1.2.5",
9
9
  "keywords": [
10
10
  "fs",
11
11
  "file",