@reliverse/relifso 1.2.9 → 1.3.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.
package/README.md CHANGED
@@ -51,7 +51,7 @@ bun dler relifso init ...
51
51
 
52
52
  ## Usage
53
53
 
54
- Check [./example/e-mod.ts](./example/e-mod.ts) for a full example. You can clone this repo and run via `bun dev`.
54
+ Check [./e-relifso.ts](./e-relifso.ts) and [./e-pathkit.ts](./e-pathkit.ts) for a full examples. You can clone this repo and run via `bun dev`.
55
55
 
56
56
  Relifso works just like `fs-extra` — every method is promise-first, ergonomic, and future-ready.
57
57
 
@@ -276,10 +276,10 @@ All async methods return a `Promise` if no callback is passed.
276
276
 
277
277
  ## TODO
278
278
 
279
- - [x] Create usage example in [./example/e-mod.ts](./example/e-mod.ts)
280
- - [ ] Ensure [./example/e-mod.ts](./example/e-mod.ts) works 100% correctly
279
+ - [x] Create usage example in [./e-relifso.ts](./e-relifso.ts) and [./e-pathkit.ts](./e-pathkit.ts)
280
+ - [ ] Ensure [./e-relifso.ts](./e-relifso.ts) and [./e-pathkit.ts](./e-pathkit.ts) works 100% correctly
281
281
  - [ ] Consider using [@reliverse/repath](https://github.com/reliverse/repath) instead of just `node:path`.
282
- - [ ] Pass all `fs-extra` tests with Bun/Vitest (+ fix & improve them).
282
+ - [ ] Pass all `fs-extra` tests with Bun (+ fix & improve them).
283
283
  - [ ] Convert all jsdoc comments to TypeScript types.
284
284
  - [ ] Fully improve all `fs-extra` codebase files.
285
285
 
package/bin/impl/copy.js CHANGED
@@ -1,5 +1,11 @@
1
- import { copyFileSync, statSync, constants as fsConstants } from "node:fs";
2
- import { stat as statAsync, copyFile as copyFileAsync, constants as fsConstantsAsync, readdir } from "node:fs/promises";
1
+ import { copyFileSync, statSync, constants as fsConstants, readdirSync, rmSync } from "node:fs";
2
+ import {
3
+ stat as statAsync,
4
+ copyFile as copyFileAsync,
5
+ constants as fsConstantsAsync,
6
+ readdir,
7
+ rm
8
+ } from "node:fs/promises";
3
9
  import { dirname, join as joinPath, basename as basenamePath } from "node:path";
4
10
  import { mkdirsSync } from "./mkdirs.js";
5
11
  import { mkdirs } from "./mkdirs.js";
@@ -10,7 +16,7 @@ export function copySync(src, dest, options = {}) {
10
16
  }
11
17
  let destFinal = dest;
12
18
  const destStat = statSync(dest, { throwIfNoEntry: false });
13
- if (destStat?.isDirectory()) {
19
+ if (!srcStat.isDirectory() && destStat?.isDirectory()) {
14
20
  destFinal = joinPath(dest, basenamePath(src));
15
21
  }
16
22
  const destExists = statSync(destFinal, { throwIfNoEntry: false });
@@ -20,8 +26,20 @@ export function copySync(src, dest, options = {}) {
20
26
  const destDir = dirname(destFinal);
21
27
  mkdirsSync(destDir);
22
28
  if (srcStat.isDirectory()) {
29
+ if (overwrite && destExists) {
30
+ rmSync(destFinal, { recursive: true, force: true });
31
+ }
23
32
  mkdirsSync(destFinal);
33
+ const entries = readdirSync(src);
34
+ for (const entry of entries) {
35
+ const srcEntry = joinPath(src, entry);
36
+ const destEntry = joinPath(destFinal, entry);
37
+ copySync(srcEntry, destEntry, options);
38
+ }
24
39
  } else {
40
+ if (overwrite && destExists) {
41
+ rmSync(destFinal, { force: true });
42
+ }
25
43
  copyFileSync(src, destFinal, preserveTimestamps ? fsConstants.COPYFILE_FICLONE : 0);
26
44
  if (preserveTimestamps) {
27
45
  console.warn("preserveTimestamps: utimesSync is not implemented for the moment.");
@@ -41,7 +59,7 @@ export async function copy(src, dest, options = {}) {
41
59
  if (e.code === "ENOENT") return null;
42
60
  throw e;
43
61
  });
44
- if (destStat?.isDirectory()) {
62
+ if (!srcStat?.isDirectory() && destStat?.isDirectory()) {
45
63
  destFinal = joinPath(dest, basenamePath(src));
46
64
  }
47
65
  const destExists = await statAsync(destFinal).catch((e) => {
@@ -54,6 +72,9 @@ export async function copy(src, dest, options = {}) {
54
72
  const destDir = dirname(destFinal);
55
73
  await mkdirs(destDir);
56
74
  if (srcStat?.isDirectory()) {
75
+ if (overwrite && destExists) {
76
+ await rm(destFinal, { recursive: true, force: true });
77
+ }
57
78
  await mkdirs(destFinal);
58
79
  const entries = await readdir(src);
59
80
  for (const entry of entries) {
@@ -62,6 +83,9 @@ export async function copy(src, dest, options = {}) {
62
83
  await copy(srcEntry, destEntry, options);
63
84
  }
64
85
  } else {
86
+ if (overwrite && destExists) {
87
+ await rm(destFinal, { force: true });
88
+ }
65
89
  await copyFileAsync(src, destFinal, preserveTimestamps ? fsConstantsAsync.COPYFILE_FICLONE : 0);
66
90
  if (preserveTimestamps) {
67
91
  console.warn("preserveTimestamps: utimes is not implemented for the moment.");
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.9",
8
+ "version": "1.3.0",
9
9
  "keywords": [
10
10
  "fs",
11
11
  "file",
@@ -35,8 +35,8 @@
35
35
  "@biomejs/biome": "1.9.4",
36
36
  "@cspotcode/source-map-support": "^0.8.1",
37
37
  "@eslint/js": "^9.27.0",
38
- "@reliverse/dler": "^1.3.6",
39
- "@reliverse/pathkit": "^1.0.4",
38
+ "@reliverse/dler": "^1.4.6",
39
+ "@reliverse/pathkit": "^1.1.5",
40
40
  "@rollup/plugin-alias": "^5.1.1",
41
41
  "@rollup/plugin-babel": "^6.0.4",
42
42
  "@rollup/plugin-commonjs": "^28.0.3",
@@ -44,7 +44,7 @@
44
44
  "@rollup/plugin-replace": "^6.0.2",
45
45
  "@rollup/plugin-terser": "^0.4.4",
46
46
  "@stylistic/eslint-plugin": "^4.2.0",
47
- "@swc/core": "^1.11.24",
47
+ "@swc/core": "^1.11.29",
48
48
  "@types/eslint": "^9.6.1",
49
49
  "@types/fs-extra": "^11.0.4",
50
50
  "@types/graceful-fs": "^4.1.9",
@@ -53,7 +53,7 @@
53
53
  "@types/klaw-sync": "^6.0.5",
54
54
  "@types/minimist": "^1.2.5",
55
55
  "@types/mocha": "^10.0.10",
56
- "@types/node": "^22.15.19",
56
+ "@types/node": "^22.15.21",
57
57
  "@types/proxyquire": "^1.3.31",
58
58
  "@types/universalify": "^1.0.3",
59
59
  "@types/verror": "^1.10.11",
@@ -69,7 +69,7 @@
69
69
  "jsonfile": "^6.1.0",
70
70
  "klaw": "^4.1.0",
71
71
  "klaw-sync": "^7.0.0",
72
- "knip": "^5.56.0",
72
+ "knip": "^5.57.2",
73
73
  "minimist": "^1.2.8",
74
74
  "mocha": "^11.4.0",
75
75
  "nyc": "^17.1.0",
@@ -104,4 +104,4 @@
104
104
  "publishConfig": {
105
105
  "access": "public"
106
106
  }
107
- }
107
+ }