@stryke/fs 0.32.8 → 0.32.9

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.
@@ -10,6 +10,7 @@ exports.copyFilesSync = copyFilesSync;
10
10
  var _path = require("@stryke/path");
11
11
  var _correctPath = require("@stryke/path/correct-path");
12
12
  var _filePathFns = require("@stryke/path/file-path-fns");
13
+ var _isType = require("@stryke/path/is-type");
13
14
  var _join = require("@stryke/path/join");
14
15
  var _replace = require("@stryke/path/replace");
15
16
  var _resolveParentPath = require("@stryke/path/resolve-parent-path");
@@ -21,33 +22,31 @@ var _exists = require("./exists.cjs");
21
22
  var _helpers = require("./helpers.cjs");
22
23
  var _isFile = require("./is-file.cjs");
23
24
  var _listFiles = require("./list-files.cjs");
24
- async function copyFile(o, s) {
25
+ async function copyFile(o, r) {
25
26
  const i = o instanceof URL ? (0, _mlly.fileURLToPath)(o) : o,
26
- t = s instanceof URL ? (0, _mlly.fileURLToPath)(s) : s;
27
+ t = r instanceof URL ? (0, _mlly.fileURLToPath)(r) : r;
27
28
  if ((0, _filePathFns.hasFileExtension)(t) ? (0, _exists.existsSync)((0, _filePathFns.findFilePath)(t)) || (await (0, _helpers.createDirectory)((0, _filePathFns.findFilePath)(t))) : (0, _exists.existsSync)((0, _resolveParentPath.resolveParentPath)(t)) || (await (0, _helpers.createDirectory)((0, _resolveParentPath.resolveParentPath)(t))), (0, _typeChecks.isString)(i) && (0, _exists.existsSync)(i)) return (0, _promises.copyFile)(i, t);
28
29
  }
29
- function copyFileSync(o, s) {
30
+ function copyFileSync(o, r) {
30
31
  const i = o instanceof URL ? (0, _mlly.fileURLToPath)(o) : o,
31
- t = s instanceof URL ? (0, _mlly.fileURLToPath)(s) : s;
32
+ t = r instanceof URL ? (0, _mlly.fileURLToPath)(r) : r;
32
33
  if ((0, _filePathFns.hasFileExtension)(t) ? (0, _exists.existsSync)((0, _filePathFns.findFilePath)(t)) || (0, _helpers.createDirectorySync)((0, _filePathFns.findFilePath)(t)) : (0, _exists.existsSync)((0, _resolveParentPath.resolveParentPath)(t)) || (0, _helpers.createDirectorySync)((0, _resolveParentPath.resolveParentPath)(t)), (0, _typeChecks.isString)(i) && (0, _exists.existsSync)(i)) return (0, _nodeFs.copyFileSync)(i, t);
33
34
  }
34
- async function copyFiles(o, s) {
35
+ async function copyFiles(o, r) {
35
36
  const i = o instanceof URL ? (0, _mlly.fileURLToPath)(o) : o,
36
- t = s instanceof URL ? (0, _mlly.fileURLToPath)(s) : s;
37
- return (0, _typeChecks.isString)(i) && (0, _isFile.isFile)(i) ? copyFile(i, t) : Promise.all((await (0, _listFiles.listFiles)(i)).map(async r => {
38
- let f = (0, _correctPath.stripStars)((0, _typeChecks.isString)(i) ? i : i.input);
39
- (0, _path.isParentPath)(r, f) || ((0, _path.isParentPath)(r, (0, _join.joinPaths)((0, _path.cwd)(), f)) ? f = (0, _join.joinPaths)((0, _path.cwd)(), f) : (0, _path.isParentPath)(r, (0, _path.cwd)()) && (f = (0, _path.cwd)()));
40
- const a = (0, _join.joinPaths)(t, (0, _replace.replacePath)(r, f));
41
- (0, _isFile.isDirectory)(r) ? await copyFiles(r, a) : await copyFile(r, a);
37
+ t = r instanceof URL ? (0, _mlly.fileURLToPath)(r) : r;
38
+ if ((0, _typeChecks.isString)(i) && (0, _isFile.isFile)(i)) return copyFile(i, t);
39
+ let s = (0, _correctPath.stripStars)((0, _typeChecks.isString)(i) ? i : i.input);
40
+ return (0, _isType.isAbsolutePath)(s) || (s = (0, _path.appendPath)(s, (0, _path.cwd)())), Promise.all((await (0, _listFiles.listFiles)(i)).map(async f => {
41
+ (0, _isFile.isDirectory)(f) ? await copyFiles(f, (0, _join.joinPaths)(t, (0, _replace.replacePath)(f, s))) : await copyFile(f, (0, _join.joinPaths)(t, (0, _replace.replacePath)(f, s)));
42
42
  }));
43
43
  }
44
- function copyFilesSync(o, s) {
44
+ function copyFilesSync(o, r) {
45
45
  const i = o instanceof URL ? (0, _mlly.fileURLToPath)(o) : o,
46
- t = s instanceof URL ? (0, _mlly.fileURLToPath)(s) : s;
47
- return (0, _typeChecks.isString)(i) && (0, _isFile.isFile)(i) ? copyFileSync(i, t) : (0, _listFiles.listFilesSync)(i).map(r => {
48
- let f = (0, _correctPath.stripStars)((0, _typeChecks.isString)(i) ? i : i.input);
49
- (0, _path.isParentPath)(r, f) || ((0, _path.isParentPath)(r, (0, _join.joinPaths)((0, _path.cwd)(), f)) ? f = (0, _join.joinPaths)((0, _path.cwd)(), f) : (0, _path.isParentPath)(r, (0, _path.cwd)()) && (f = (0, _path.cwd)()));
50
- const a = (0, _join.joinPaths)(t, (0, _replace.replacePath)(r, f));
51
- (0, _isFile.isDirectory)(r) ? copyFilesSync(r, a) : copyFileSync(r, a);
46
+ t = r instanceof URL ? (0, _mlly.fileURLToPath)(r) : r;
47
+ if ((0, _typeChecks.isString)(i) && (0, _isFile.isFile)(i)) return copyFileSync(i, t);
48
+ let s = (0, _correctPath.stripStars)((0, _typeChecks.isString)(i) ? i : i.input);
49
+ return (0, _isType.isAbsolutePath)(s) || (s = (0, _path.appendPath)(s, (0, _path.cwd)())), (0, _listFiles.listFilesSync)(i).map(f => {
50
+ (0, _isFile.isDirectory)(f) ? copyFilesSync(f, (0, _replace.replacePath)(f, s)) : copyFileSync(f, (0, _replace.replacePath)(f, s));
52
51
  });
53
52
  }
@@ -1 +1 @@
1
- import{cwd as e,isParentPath as n}from"@stryke/path";import{stripStars as U}from"@stryke/path/correct-path";import{findFilePath as L,hasFileExtension as F}from"@stryke/path/file-path-fns";import{joinPaths as p}from"@stryke/path/join";import{replacePath as u}from"@stryke/path/replace";import{resolveParentPath as R}from"@stryke/path/resolve-parent-path";import{isString as m}from"@stryke/type-checks";import{fileURLToPath as c}from"mlly";import{copyFileSync as x}from"node:fs";import{copyFile as b}from"node:fs/promises";import{existsSync as l}from"./exists";import{createDirectory as y,createDirectorySync as g}from"./helpers";import{isDirectory as S,isFile as w}from"./is-file";import{listFiles as A,listFilesSync as D}from"./list-files";export async function copyFile(o,s){const i=o instanceof URL?c(o):o,t=s instanceof URL?c(s):s;if(F(t)?l(L(t))||await y(L(t)):l(R(t))||await y(R(t)),m(i)&&l(i))return b(i,t)}export function copyFileSync(o,s){const i=o instanceof URL?c(o):o,t=s instanceof URL?c(s):s;if(F(t)?l(L(t))||g(L(t)):l(R(t))||g(R(t)),m(i)&&l(i))return x(i,t)}export async function copyFiles(o,s){const i=o instanceof URL?c(o):o,t=s instanceof URL?c(s):s;return m(i)&&w(i)?copyFile(i,t):Promise.all((await A(i)).map(async r=>{let f=U(m(i)?i:i.input);n(r,f)||(n(r,p(e(),f))?f=p(e(),f):n(r,e())&&(f=e()));const a=p(t,u(r,f));S(r)?await copyFiles(r,a):await copyFile(r,a)}))}export function copyFilesSync(o,s){const i=o instanceof URL?c(o):o,t=s instanceof URL?c(s):s;return m(i)&&w(i)?copyFileSync(i,t):D(i).map(r=>{let f=U(m(i)?i:i.input);n(r,f)||(n(r,p(e(),f))?f=p(e(),f):n(r,e())&&(f=e()));const a=p(t,u(r,f));S(r)?copyFilesSync(r,a):copyFileSync(r,a)})}
1
+ import{appendPath as a,cwd as L}from"@stryke/path";import{stripStars as R}from"@stryke/path/correct-path";import{findFilePath as p,hasFileExtension as U}from"@stryke/path/file-path-fns";import{isAbsolutePath as y}from"@stryke/path/is-type";import{joinPaths as u}from"@stryke/path/join";import{replacePath as m}from"@stryke/path/replace";import{resolveParentPath as l}from"@stryke/path/resolve-parent-path";import{isString as c}from"@stryke/type-checks";import{fileURLToPath as e}from"mlly";import{copyFileSync as x}from"node:fs";import{copyFile as b}from"node:fs/promises";import{existsSync as n}from"./exists";import{createDirectory as F,createDirectorySync as g}from"./helpers";import{isDirectory as S,isFile as w}from"./is-file";import{listFiles as A,listFilesSync as D}from"./list-files";export async function copyFile(o,r){const i=o instanceof URL?e(o):o,t=r instanceof URL?e(r):r;if(U(t)?n(p(t))||await F(p(t)):n(l(t))||await F(l(t)),c(i)&&n(i))return b(i,t)}export function copyFileSync(o,r){const i=o instanceof URL?e(o):o,t=r instanceof URL?e(r):r;if(U(t)?n(p(t))||g(p(t)):n(l(t))||g(l(t)),c(i)&&n(i))return x(i,t)}export async function copyFiles(o,r){const i=o instanceof URL?e(o):o,t=r instanceof URL?e(r):r;if(c(i)&&w(i))return copyFile(i,t);let s=R(c(i)?i:i.input);return y(s)||(s=a(s,L())),Promise.all((await A(i)).map(async f=>{S(f)?await copyFiles(f,u(t,m(f,s))):await copyFile(f,u(t,m(f,s)))}))}export function copyFilesSync(o,r){const i=o instanceof URL?e(o):o,t=r instanceof URL?e(r):r;if(c(i)&&w(i))return copyFileSync(i,t);let s=R(c(i)?i:i.input);return y(s)||(s=a(s,L())),D(i).map(f=>{S(f)?copyFilesSync(f,m(f,s)):copyFileSync(f,m(f,s))})}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/fs",
3
- "version": "0.32.8",
3
+ "version": "0.32.9",
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": {
@@ -409,5 +409,5 @@
409
409
  "main": "./dist/index.cjs",
410
410
  "module": "./dist/index.mjs",
411
411
  "types": "./dist/index.d.ts",
412
- "gitHead": "39c2e3311f9f1246241a55748436981aa65e3ced"
412
+ "gitHead": "5d7b789d5e1a22fbbc460777288e51c626f0118d"
413
413
  }