@js-utils-kit/fs 1.4.0 → 1.6.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/dist/index.cjs +1 -1
- package/dist/index.d.cts +7 -1
- package/dist/index.d.mts +7 -1
- package/dist/index.mjs +1 -1
- package/package.json +13 -13
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`fs`);c=s(c);let l=require(`path`);l=s(l);let u=require(`archiver`);u=s(u);let d=require(`url`);function
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`fs`);c=s(c);let l=require(`path`);l=s(l);let u=require(`archiver`);u=s(u);let d=require(`node:fs/promises`),f=require(`url`);function p({format:e,source:t,destination:n,options:r={},log:i=!0,onSuccess:a}){let o=l.default.resolve(t);if(!c.default.existsSync(o)||!c.default.statSync(o).isDirectory())throw Error(`Source directory "${t}" does not exist or is not a directory.`);let s=c.default.createWriteStream(n);e===`zip`&&(r={...r,zlib:{level:9}});let d=(0,u.default)(e,r);return new Promise((e,r)=>{s.on(`close`,()=>{let t=d.pointer();i&&console.log(`${n} created: ${t} total bytes`),a&&a(t),e()}),d.on(`error`,e=>{r(e)}),d.pipe(s),d.directory(t,!1),d.finalize().catch(e=>r(e instanceof Error?e:Error(String(e))))})}const m=typeof __filename<`u`;async function h(e){try{return await(0,d.access)(e),!0}catch{return!1}}function g(e){if(!e)throw Error(`locateModuleFile requires import.meta.url (ESM) or __filename (CJS).`);return e.startsWith(`file:`)?(0,f.fileURLToPath)(e):e}function _(e){return l.default.dirname(g(e))}function v(e,t){let n=_(t),r=l.default.resolve(n,e);if(l.default.relative(n,r).startsWith(`..`))throw Error(`Resolved path escapes module directory.`);return r}function y(e){return e.replace(/\\/g,`/`)}function b(e){return e.replace(/\//g,`\\`)}function x(e){return e.replace(/[/\\]/g,l.default.sep)}exports.createArchive=p,exports.exists=h,exports.hasCommonJSFilename=m,exports.locateModuleDirectory=_,exports.locateModuleFile=g,exports.resolveModuleRelative=v,exports.toPlatformPath=x,exports.toPosixPath=y,exports.toWinPath=b;
|
package/dist/index.d.cts
CHANGED
|
@@ -54,6 +54,12 @@ declare function createArchive({
|
|
|
54
54
|
*/
|
|
55
55
|
declare const hasCommonJSFilename: boolean;
|
|
56
56
|
//#endregion
|
|
57
|
+
//#region src/file.d.ts
|
|
58
|
+
/** Check whether a file or directory exists */
|
|
59
|
+
declare function exists(/** Absolute or relative path to check */
|
|
60
|
+
|
|
61
|
+
path: string): Promise<boolean>;
|
|
62
|
+
//#endregion
|
|
57
63
|
//#region src/locator.d.ts
|
|
58
64
|
/**
|
|
59
65
|
* Returns the absolute file path of a module.
|
|
@@ -209,4 +215,4 @@ declare function toPlatformPath(/** The path to convert */
|
|
|
209
215
|
|
|
210
216
|
p: string): string;
|
|
211
217
|
//#endregion
|
|
212
|
-
export { createArchive, hasCommonJSFilename, locateModuleDirectory, locateModuleFile, resolveModuleRelative, toPlatformPath, toPosixPath, toWinPath };
|
|
218
|
+
export { createArchive, exists, hasCommonJSFilename, locateModuleDirectory, locateModuleFile, resolveModuleRelative, toPlatformPath, toPosixPath, toWinPath };
|
package/dist/index.d.mts
CHANGED
|
@@ -54,6 +54,12 @@ declare function createArchive({
|
|
|
54
54
|
*/
|
|
55
55
|
declare const hasCommonJSFilename: boolean;
|
|
56
56
|
//#endregion
|
|
57
|
+
//#region src/file.d.ts
|
|
58
|
+
/** Check whether a file or directory exists */
|
|
59
|
+
declare function exists(/** Absolute or relative path to check */
|
|
60
|
+
|
|
61
|
+
path: string): Promise<boolean>;
|
|
62
|
+
//#endregion
|
|
57
63
|
//#region src/locator.d.ts
|
|
58
64
|
/**
|
|
59
65
|
* Returns the absolute file path of a module.
|
|
@@ -209,4 +215,4 @@ declare function toPlatformPath(/** The path to convert */
|
|
|
209
215
|
|
|
210
216
|
p: string): string;
|
|
211
217
|
//#endregion
|
|
212
|
-
export { createArchive, hasCommonJSFilename, locateModuleDirectory, locateModuleFile, resolveModuleRelative, toPlatformPath, toPosixPath, toWinPath };
|
|
218
|
+
export { createArchive, exists, hasCommonJSFilename, locateModuleDirectory, locateModuleFile, resolveModuleRelative, toPlatformPath, toPosixPath, toWinPath };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"fs";import t from"path";import n from"archiver";import{
|
|
1
|
+
import e from"fs";import t from"path";import n from"archiver";import{access as r}from"node:fs/promises";import{fileURLToPath as i}from"url";function a({format:r,source:i,destination:a,options:o={},log:s=!0,onSuccess:c}){let l=t.resolve(i);if(!e.existsSync(l)||!e.statSync(l).isDirectory())throw Error(`Source directory "${i}" does not exist or is not a directory.`);let u=e.createWriteStream(a);r===`zip`&&(o={...o,zlib:{level:9}});let d=n(r,o);return new Promise((e,t)=>{u.on(`close`,()=>{let t=d.pointer();s&&console.log(`${a} created: ${t} total bytes`),c&&c(t),e()}),d.on(`error`,e=>{t(e)}),d.pipe(u),d.directory(i,!1),d.finalize().catch(e=>t(e instanceof Error?e:Error(String(e))))})}const o=typeof __filename<`u`;async function s(e){try{return await r(e),!0}catch{return!1}}function c(e){if(!e)throw Error(`locateModuleFile requires import.meta.url (ESM) or __filename (CJS).`);return e.startsWith(`file:`)?i(e):e}function l(e){return t.dirname(c(e))}function u(e,n){let r=l(n),i=t.resolve(r,e);if(t.relative(r,i).startsWith(`..`))throw Error(`Resolved path escapes module directory.`);return i}function d(e){return e.replace(/\\/g,`/`)}function f(e){return e.replace(/\//g,`\\`)}function p(e){return e.replace(/[/\\]/g,t.sep)}export{a as createArchive,s as exists,o as hasCommonJSFilename,l as locateModuleDirectory,c as locateModuleFile,u as resolveModuleRelative,p as toPlatformPath,d as toPosixPath,f as toWinPath};
|
package/package.json
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@js-utils-kit/fs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "File system utilities",
|
|
5
|
-
"private": false,
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"author": {
|
|
8
|
-
"name": "Sriman",
|
|
9
|
-
"email": "136729116+TenEplaysOfficial@users.noreply.github.com",
|
|
10
|
-
"url": "https://tene.vercel.app"
|
|
11
|
-
},
|
|
12
5
|
"homepage": "https://js-utils.js.org",
|
|
13
6
|
"repository": {
|
|
14
7
|
"type": "git",
|
|
@@ -18,25 +11,32 @@
|
|
|
18
11
|
"bugs": {
|
|
19
12
|
"url": "https://github.com/teneplaysofficial/js-utils-kit/issues"
|
|
20
13
|
},
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"author": {
|
|
16
|
+
"name": "Sriman",
|
|
17
|
+
"email": "136729116+TenEplaysOfficial@users.noreply.github.com",
|
|
18
|
+
"url": "https://tene.vercel.app"
|
|
19
|
+
},
|
|
20
|
+
"private": false,
|
|
21
21
|
"files": [
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
|
-
"engines": {
|
|
25
|
-
"node": ">=22"
|
|
26
|
-
},
|
|
27
24
|
"type": "module",
|
|
28
25
|
"main": "./dist/index.cjs",
|
|
29
26
|
"module": "./dist/index.mjs",
|
|
30
|
-
"types": "./dist/index.d.cts",
|
|
31
27
|
"exports": {
|
|
32
28
|
".": {
|
|
33
29
|
"import": "./dist/index.mjs",
|
|
34
30
|
"require": "./dist/index.cjs"
|
|
35
31
|
}
|
|
36
32
|
},
|
|
33
|
+
"types": "./dist/index.d.cts",
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=22"
|
|
36
|
+
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"archiver": "^7.0.1",
|
|
39
|
-
"@js-utils-kit/types": "1.
|
|
39
|
+
"@js-utils-kit/types": "1.5.0"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "tsdown",
|