@jestaubach/fs-helpers 0.2.16 → 0.2.17
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 +1 -1
- package/dist/fs-helpers.js +2 -2
- package/dist/fs-helpers.umd.cjs +1 -1
- package/dist/index.d.ts +6 -3
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
# fs-helpers
|
|
1
|
+
# fs-helpers
|
package/dist/fs-helpers.js
CHANGED
package/dist/fs-helpers.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(a,n){typeof exports=="object"&&typeof module<"u"?module.exports=n():typeof define=="function"&&define.amd?define(n):(a=typeof globalThis<"u"?globalThis:a||self,a["fs-helpers"]=n())})(this,function(){"use strict";var Q=Object.defineProperty;var U=(a,n,s)=>n in a?Q(a,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[n]=s;var D=(a,n,s)=>(U(a,typeof n!="symbol"?n+"":n,s),s);const{default:a}=(()=>{const e=require("fs-extra");return e&&e.__esModule?e:Object.assign(Object.create(null),e,{default:e,[Symbol.toStringTag]:"Module"})})(),{default:n}=(()=>{const e=require("path");return e&&e.__esModule?e:Object.assign(Object.create(null),e,{default:e,[Symbol.toStringTag]:"Module"})})(),s=new Map;function E(e){const{root:o,dir:i}=n.parse(e),u=i.split(o).slice(1).join(o).split(n.sep);for(let f=0;f<u.length;f++){const v=[o,u.slice(0,f+1).join(n.sep)].join("");b(v)}const c=a.readFileSync(e).toString();m(e,c)}function k(e,o){const[i,u]=s.get(e)||["",""];return Buffer.from(u)}function m(e,o,i){s.set(e,["file",o])}function $(e){return e===n.resolve(".")?!0:s.has(e)}function h(e,o){const[i,u]=s.get(e)||["",""],c={isDirectory:()=>e===n.resolve(".")?!0:i==="dir",isFile:()=>s.has(e)&&i==="file",isBlockDevice:()=>!1,isCharacterDevice:()=>!1,isSymbolicLink:()=>!1,isFIFO:()=>!1,isSocket:()=>!1,dev:0,ino:0,mode:0,nlink:0,uid:0,gid:0,rdev:0,size:0,blksize:0,blocks:0,atimeMs:0,mtimeMs:0,ctimeMs:0,birthtimeMs:0,atime:new Date(0),mtime:new Date(0),ctime:new Date(0),birthtime:new Date(0)};return c.isBlockDevice(),c.isCharacterDevice(),c.isSymbolicLink(),c.isFIFO(),c.isSocket(),c}function F(e,o){}class x extends Error{constructor(i){super(i);D(this,"code");this.code="ENOENT"}}function _(e,o){if(!s.has(e))throw new x("source path not found");for(const i of Array.from(s.keys()))if(i.includes(e)){const u=i.split(e).join(o),c=s.get(i)||["",""];s.delete(i),s.set(u,c)}}function j(e,o,i){if(s.has(o))throw Error("destination directory exists");for(const u of Array.from(s.keys()))if(u.includes(e)){const c=u.split(e).join(o);s.set(c,s.get(u)||["",""])}}function b(e){if(h(e).isFile())throw Error("file exists at destination");let o;const i=e.split(n.resolve(".")).join("").split(n.sep);for(let u=0;u<i.length;u++){const c=i.slice(0,u+1).join(n.sep);!s.has(`${n.resolve(".")}${c}`)&&c!==""&&(s.set(`${n.resolve(".")}${c}`,["dir",""]),o=o??`${n.resolve(".")}${c}`)}return o}function w(e){for(const o of Array.from(s.keys()))o.includes(e)&&s.delete(o)}function M(e){s.has(e)||s.set(e,["file",""])}const O={existsSync:$,lstatSync:h,chmodSync:F,renameSync:_,readFileSync:k,copySync:j,removeSync:w,ensureFileSync:M,mkdirpSync:b,outputFileSync:m,seedFile:E},{default:T}=(()=>{const e=require("fs-extra");return e&&e.__esModule?e:Object.assign(Object.create(null),e,{default:e,[Symbol.toStringTag]:"Module"})})(),{default:S}=(()=>{const e=require("path");return e&&e.__esModule?e:Object.assign(Object.create(null),e,{default:e,[Symbol.toStringTag]:"Module"})})();function A(e,o){const{existsSync:i,lstatSync:u,chmodSync:c,renameSync:f,readFileSync:v,copySync:C,removeSync:I,ensureFileSync:N,outputFileSync:q,mkdirpSync:z,seedFile:g}=e;if(g!==void 0&&o!==void 0)for(const r of o)R(r);function R(r){const t=l(r).value;g(t)}function B(r){return{success:!0,value:v(l(r).value),error:null}}function L(r,t){return q(l(r).value,t),{success:!0,error:null}}function P(r){const t=l(r).value;return i(t)?u(t).isFile()?{success:!0,value:!0,error:null}:{success:!1,value:!1,error:`checkIfFileExists: '${r}' is not a file.`}:{success:!0,value:!1,error:null}}function y(r){const t=l(r).value;return i(t)?u(t).isDirectory()?{success:!0,value:!0,error:null}:{success:!1,value:!1,error:`checkIfDirExists: '${r}' is not a directory.`}:{success:!0,value:!1,error:null}}function l(r){try{if(r===void 0)throw Error("Dir is undefined.");if(r.match(/^[.a-zA-Z0-9\-_/:\\]+$/g)===null)throw Error(`Dir contains unsupported characters. Received ${r}.`);return{success:!0,value:S.normalize(S.resolve(r)),error:null}}catch(t){return console.error(`Error resolving path: ${r}`),{success:!1,value:void 0,error:`Error resolving path: '${r}'. Received error: '${t}'`}}}function V(r){try{if(r===void 0)throw Error(`Function "createDir" expected a path. Recieved "${r}".`);const t=l(r).value;return{success:!0,value:z(t),error:null}}catch{return console.error(`Error creating dir: ${r}`),{success:!1,value:void 0,error:`Error creating dir: '${r}'`}}}function J(r,t){const d=l(r).value;return N(d),t!==void 0&&c(d,t),{success:!0,error:null}}function p(r){return l(r).value!==void 0&&y(r).value?(I(r),{success:!0,value:r,error:null}):(console.error(`Error deleting dir: ${r}`),{success:!1,value:void 0,error:`Error deleting dir: '${r}'`})}function Z(r){return r.map(t=>p(l(t).value))}function G(r){return r!==null&&y(r).value?(console.error(`Cleaning up due to abort, directories created starting at: ${JSON.stringify(r)}`),p(r),{success:!0,error:null}):(console.error("Cleaning up due to abort, no directory to clean up."),{success:!1,error:"Cleaning up due to abort, no directory to clean up."})}function H(r,t){try{return f(l(r).value,l(t).value),{success:!0,value:"Successfully renamed the directory.",error:null}}catch(d){return console.error(d.code),{success:!1,value:void 0,error:`renameDir from '${r}' to '${t} failed.`}}}function K(r,t){try{return C(l(r).value,l(t).value,{overwrite:!1,errorOnExist:!0}),{success:!0,error:null}}catch{return{success:!1,error:`Error copying absolute from '${r}' to '${t}'`}}}return{getAbsolutePath:l,abortDirCreation:G,checkIfDirExists:y,copyDirAbs:K,createDir:V,renameDir:H,rimrafDir:p,rimrafDirs:Z,checkIfFileExists:P,readFile:B,writeFile:L,touchFile:J}}return{use:A,default:T,mock:O}});
|
|
1
|
+
(function(a,n){typeof exports=="object"&&typeof module<"u"?module.exports=n():typeof define=="function"&&define.amd?define(n):(a=typeof globalThis<"u"?globalThis:a||self,a["fs-helpers"]=n())})(this,function(){"use strict";var Q=Object.defineProperty;var U=(a,n,s)=>n in a?Q(a,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[n]=s;var D=(a,n,s)=>(U(a,typeof n!="symbol"?n+"":n,s),s);const{default:a}=(()=>{const e=require("fs-extra");return e&&e.__esModule?e:Object.assign(Object.create(null),e,{default:e,[Symbol.toStringTag]:"Module"})})(),{default:n}=(()=>{const e=require("path");return e&&e.__esModule?e:Object.assign(Object.create(null),e,{default:e,[Symbol.toStringTag]:"Module"})})(),s=new Map;function E(e){const{root:o,dir:i}=n.parse(e),u=i.split(o).slice(1).join(o).split(n.sep);for(let f=0;f<u.length;f++){const v=[o,u.slice(0,f+1).join(n.sep)].join("");b(v)}const c=a.readFileSync(e).toString();m(e,c)}function k(e,o){const[i,u]=s.get(e)||["",""];return Buffer.from(u)}function m(e,o,i){s.set(e,["file",o])}function $(e){return e===n.resolve(".")?!0:s.has(e)}function h(e,o){const[i,u]=s.get(e)||["",""],c={isDirectory:()=>e===n.resolve(".")?!0:i==="dir",isFile:()=>s.has(e)&&i==="file",isBlockDevice:()=>!1,isCharacterDevice:()=>!1,isSymbolicLink:()=>!1,isFIFO:()=>!1,isSocket:()=>!1,dev:0,ino:0,mode:0,nlink:0,uid:0,gid:0,rdev:0,size:0,blksize:0,blocks:0,atimeMs:0,mtimeMs:0,ctimeMs:0,birthtimeMs:0,atime:new Date(0),mtime:new Date(0),ctime:new Date(0),birthtime:new Date(0)};return c.isBlockDevice(),c.isCharacterDevice(),c.isSymbolicLink(),c.isFIFO(),c.isSocket(),c}function F(e,o){}class x extends Error{constructor(i){super(i);D(this,"code");this.code="ENOENT"}}function _(e,o){if(!s.has(e))throw new x("source path not found");for(const i of Array.from(s.keys()))if(i.includes(e)){const u=i.split(e).join(o),c=s.get(i)||["",""];s.delete(i),s.set(u,c)}}function j(e,o,i){if(s.has(o))throw Error("destination directory exists");for(const u of Array.from(s.keys()))if(u.includes(e)){const c=u.split(e).join(o);s.set(c,s.get(u)||["",""])}}function b(e){if(h(e).isFile())throw Error("file exists at destination");let o;const i=e.split(n.resolve(".")).join("").split(n.sep);for(let u=0;u<i.length;u++){const c=i.slice(0,u+1).join(n.sep);!s.has(`${n.resolve(".")}${c}`)&&c!==""&&(s.set(`${n.resolve(".")}${c}`,["dir",""]),o=o??`${n.resolve(".")}${c}`)}return o}function w(e){for(const o of Array.from(s.keys()))o.includes(e)&&s.delete(o)}function M(e){s.has(e)||s.set(e,["file",""])}const O={existsSync:$,lstatSync:h,chmodSync:F,renameSync:_,readFileSync:k,copySync:j,removeSync:w,ensureFileSync:M,mkdirpSync:b,outputFileSync:m,seedFile:E},{default:T}=(()=>{const e=require("fs-extra");return e&&e.__esModule?e:Object.assign(Object.create(null),e,{default:e,[Symbol.toStringTag]:"Module"})})(),{default:S}=(()=>{const e=require("path");return e&&e.__esModule?e:Object.assign(Object.create(null),e,{default:e,[Symbol.toStringTag]:"Module"})})();function A(e,o){const{existsSync:i,lstatSync:u,chmodSync:c,renameSync:f,readFileSync:v,copySync:C,removeSync:I,ensureFileSync:N,outputFileSync:q,mkdirpSync:z,seedFile:g}=e;if(g!==void 0&&o!==void 0)for(const r of o)R(r);function R(r){const t=l(r).value;g(t)}function B(r,t){return{success:!0,value:v(l(r).value,t),error:null}}function L(r,t){return q(l(r).value,t),{success:!0,error:null}}function P(r){const t=l(r).value;return i(t)?u(t).isFile()?{success:!0,value:!0,error:null}:{success:!1,value:!1,error:`checkIfFileExists: '${r}' is not a file.`}:{success:!0,value:!1,error:null}}function y(r){const t=l(r).value;return i(t)?u(t).isDirectory()?{success:!0,value:!0,error:null}:{success:!1,value:!1,error:`checkIfDirExists: '${r}' is not a directory.`}:{success:!0,value:!1,error:null}}function l(r){try{if(r===void 0)throw Error("Dir is undefined.");if(r.match(/^[.a-zA-Z0-9\-_/:\\]+$/g)===null)throw Error(`Dir contains unsupported characters. Received ${r}.`);return{success:!0,value:S.normalize(S.resolve(r)),error:null}}catch(t){return console.error(`Error resolving path: ${r}`),{success:!1,value:void 0,error:`Error resolving path: '${r}'. Received error: '${t}'`}}}function V(r){try{if(r===void 0)throw Error(`Function "createDir" expected a path. Recieved "${r}".`);const t=l(r).value;return{success:!0,value:z(t),error:null}}catch{return console.error(`Error creating dir: ${r}`),{success:!1,value:void 0,error:`Error creating dir: '${r}'`}}}function J(r,t){const d=l(r).value;return N(d),t!==void 0&&c(d,t),{success:!0,error:null}}function p(r){return l(r).value!==void 0&&y(r).value?(I(r),{success:!0,value:r,error:null}):(console.error(`Error deleting dir: ${r}`),{success:!1,value:void 0,error:`Error deleting dir: '${r}'`})}function Z(r){return r.map(t=>p(l(t).value))}function G(r){return r!==null&&y(r).value?(console.error(`Cleaning up due to abort, directories created starting at: ${JSON.stringify(r)}`),p(r),{success:!0,error:null}):(console.error("Cleaning up due to abort, no directory to clean up."),{success:!1,error:"Cleaning up due to abort, no directory to clean up."})}function H(r,t){try{return f(l(r).value,l(t).value),{success:!0,value:"Successfully renamed the directory.",error:null}}catch(d){return console.error(d.code),{success:!1,value:void 0,error:`renameDir from '${r}' to '${t} failed.`}}}function K(r,t){try{return C(l(r).value,l(t).value,{overwrite:!1,errorOnExist:!0}),{success:!0,error:null}}catch{return{success:!1,error:`Error copying absolute from '${r}' to '${t}'`}}}return{getAbsolutePath:l,abortDirCreation:G,checkIfDirExists:y,copyDirAbs:K,createDir:V,renameDir:H,rimrafDir:p,rimrafDirs:Z,checkIfFileExists:P,readFile:B,writeFile:L,touchFile:J}}return{use:A,default:T,mock:O}});
|
package/dist/index.d.ts
CHANGED
|
@@ -12,15 +12,18 @@ declare const _default: {
|
|
|
12
12
|
}) | undefined) => fsExtra.Stats;
|
|
13
13
|
chmodSync: (_filePath: fsExtra.PathLike, _mode: fsExtra.Mode) => void;
|
|
14
14
|
renameSync: (oldPath: fsExtra.PathLike, newPath: fsExtra.PathLike) => void;
|
|
15
|
-
readFileSync: (filePath: string, _options?: {
|
|
15
|
+
readFileSync: (filePath: string, _options?: BufferEncoding | {
|
|
16
16
|
encoding: BufferEncoding;
|
|
17
17
|
flag?: string | undefined;
|
|
18
|
-
} |
|
|
18
|
+
} | undefined) => Buffer;
|
|
19
19
|
copySync: (src: string, dest: string, _options?: fsExtra.CopyOptionsSync | undefined) => void;
|
|
20
20
|
removeSync: (filePath: string) => void;
|
|
21
21
|
ensureFileSync: (filename: string) => void;
|
|
22
22
|
mkdirpSync: (dir: string) => any;
|
|
23
|
-
outputFileSync: (filename: string, data: string, _options?: string | fsExtra.
|
|
23
|
+
outputFileSync: (filename: string, data: string, _options?: string | (fsExtra.ObjectEncodingOptions & import("events").Abortable & {
|
|
24
|
+
mode?: fsExtra.Mode | undefined;
|
|
25
|
+
flag?: string | undefined;
|
|
26
|
+
}) | null | undefined) => void;
|
|
24
27
|
seedFile: (fileName: string) => void;
|
|
25
28
|
};
|
|
26
29
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jestaubach/fs-helpers",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/fs-helpers.umd.cjs",
|
|
6
6
|
"module": "./dist/fs-helpers.js",
|
|
@@ -30,24 +30,24 @@
|
|
|
30
30
|
],
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "tsc && vite build",
|
|
33
|
-
"test": "vitest run --coverage"
|
|
33
|
+
"test": "vitest run --coverage --reporter dot"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"builtin-modules": "^3.3.0",
|
|
37
|
-
"fs-extra": "^
|
|
37
|
+
"fs-extra": "^11.1.1",
|
|
38
38
|
"lodash": "^4.17.21",
|
|
39
|
-
"mkdirp": "^
|
|
39
|
+
"mkdirp": "^3.0.1",
|
|
40
40
|
"vite-plugin-commonjs-externals": "^0.1.3"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@types/fs-extra": "^
|
|
43
|
+
"@types/fs-extra": "^11.0.1",
|
|
44
44
|
"@types/lodash": "^4.14.195",
|
|
45
|
-
"@types/mkdirp": "^
|
|
46
|
-
"@types/node": "^
|
|
47
|
-
"@vitest/coverage-istanbul": "^0.
|
|
48
|
-
"typescript": "^
|
|
45
|
+
"@types/mkdirp": "^2.0.0",
|
|
46
|
+
"@types/node": "^20.3.3",
|
|
47
|
+
"@vitest/coverage-istanbul": "^0.33.0",
|
|
48
|
+
"typescript": "^5.1.6",
|
|
49
49
|
"vite": "^4.3.9",
|
|
50
|
-
"vite-plugin-dts": "^
|
|
51
|
-
"vitest": "^0.
|
|
50
|
+
"vite-plugin-dts": "^3.0.3",
|
|
51
|
+
"vitest": "^0.33.0"
|
|
52
52
|
}
|
|
53
53
|
}
|