@stryke/fs 0.5.0 → 0.5.1
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/files/helpers.cjs
CHANGED
|
@@ -7,6 +7,8 @@ exports.createDirectory = createDirectory;
|
|
|
7
7
|
exports.createDirectorySync = createDirectorySync;
|
|
8
8
|
exports.extractFileFromTar = extractFileFromTar;
|
|
9
9
|
exports.extractFileFromTarGzip = extractFileFromTarGzip;
|
|
10
|
+
exports.removeDirectory = removeDirectory;
|
|
11
|
+
exports.removeDirectorySync = removeDirectorySync;
|
|
10
12
|
var _nodeFs = require("node:fs");
|
|
11
13
|
var _promises = require("node:fs/promises");
|
|
12
14
|
var _exists = require("@stryke/path/utilities/exists");
|
|
@@ -21,15 +23,25 @@ async function createDirectory(r) {
|
|
|
21
23
|
recursive: !0
|
|
22
24
|
});
|
|
23
25
|
}
|
|
26
|
+
function removeDirectorySync(r) {
|
|
27
|
+
if ((0, _exists.existsSync)(r)) return (0, _nodeFs.rmdirSync)(r, {
|
|
28
|
+
recursive: !0
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
async function removeDirectory(r) {
|
|
32
|
+
if ((0, _exists.existsSync)(r)) return (0, _promises.rmdir)(r, {
|
|
33
|
+
recursive: !0
|
|
34
|
+
});
|
|
35
|
+
}
|
|
24
36
|
async function extractFileFromTar(r, i, t) {
|
|
25
|
-
const e = (0, _nanotar.parseTar)(await (0, _promises.readFile)(r)).find(
|
|
37
|
+
const e = (0, _nanotar.parseTar)(await (0, _promises.readFile)(r)).find(n => n.name === i);
|
|
26
38
|
if (!e?.data) return;
|
|
27
39
|
(await (0, _exists.exists)(t)) || (await (0, _promises.mkdir)(t, {
|
|
28
40
|
recursive: !0
|
|
29
41
|
})), (0, _nodeFs.createWriteStream)(t).write(e.data);
|
|
30
42
|
}
|
|
31
43
|
async function extractFileFromTarGzip(r, i, t) {
|
|
32
|
-
const e = (await (0, _nanotar.parseTarGzip)(await (0, _promises.readFile)(r))).find(
|
|
44
|
+
const e = (await (0, _nanotar.parseTarGzip)(await (0, _promises.readFile)(r))).find(n => n.name === i);
|
|
33
45
|
if (!e?.data) return;
|
|
34
46
|
(await (0, _exists.exists)(t)) || (await (0, _promises.mkdir)(t, {
|
|
35
47
|
recursive: !0
|
package/dist/files/helpers.d.ts
CHANGED
|
@@ -1,17 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Create a directory if it does not exist.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
4
|
+
* @param path - The directory path to check
|
|
5
5
|
* @returns An indicator specifying if the directory exists
|
|
6
6
|
*/
|
|
7
7
|
export declare function createDirectorySync(path: string): string | undefined;
|
|
8
8
|
/**
|
|
9
9
|
* Create a directory if it does not exist.
|
|
10
10
|
*
|
|
11
|
-
* @param
|
|
11
|
+
* @param path - The directory path to check
|
|
12
12
|
* @returns An indicator specifying if the directory exists
|
|
13
13
|
*/
|
|
14
14
|
export declare function createDirectory(path: string): Promise<string | undefined>;
|
|
15
|
+
/**
|
|
16
|
+
* Remove a directory if it exists.
|
|
17
|
+
*
|
|
18
|
+
* @param path - The directory path to check
|
|
19
|
+
* @returns An indicator specifying if the directory exists
|
|
20
|
+
*/
|
|
21
|
+
export declare function removeDirectorySync(path: string): void;
|
|
22
|
+
/**
|
|
23
|
+
* Remove a directory if it exists.
|
|
24
|
+
*
|
|
25
|
+
* @param path - The directory path to check
|
|
26
|
+
* @returns An indicator specifying if the directory exists
|
|
27
|
+
*/
|
|
28
|
+
export declare function removeDirectory(path: string): Promise<void>;
|
|
15
29
|
/**
|
|
16
30
|
* Extracts a file from a given tarball to the specified destination.
|
|
17
31
|
*
|
package/dist/files/helpers.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createWriteStream as
|
|
1
|
+
import{createWriteStream as u,mkdirSync as y,rmdirSync as g}from"node:fs";import{mkdir as c,readFile as o,rmdir as p}from"node:fs/promises";import{exists as s,existsSync as a}from"@stryke/path/utilities/exists";import{parseTar as w,parseTarGzip as x}from"nanotar";export function createDirectorySync(r){if(!a(r))return y(r,{recursive:!0})}export async function createDirectory(r){if(!await s(r))return c(r,{recursive:!0})}export function removeDirectorySync(r){if(a(r))return g(r,{recursive:!0})}export async function removeDirectory(r){if(a(r))return p(r,{recursive:!0})}export async function extractFileFromTar(r,i,t){const e=w(await o(r)).find(n=>n.name===i);if(!e?.data)return;await s(t)||await c(t,{recursive:!0}),u(t).write(e.data)}export async function extractFileFromTarGzip(r,i,t){const e=(await x(await o(r))).find(n=>n.name===i);if(!e?.data)return;await s(t)||await c(t,{recursive:!0}),u(t).write(e.data)}
|
|
@@ -10,7 +10,7 @@ const removeFileSync = r => {
|
|
|
10
10
|
if (!r || !(0, _nodeFs.existsSync)(r)) throw new Error("Invalid file path provided to remove data");
|
|
11
11
|
(0, _nodeFs.rmSync)(r);
|
|
12
12
|
},
|
|
13
|
-
removeFile = r => {
|
|
13
|
+
removeFile = async r => {
|
|
14
14
|
if (!r || !(0, _nodeFs.existsSync)(r)) throw new Error("Invalid file path provided to remove data");
|
|
15
15
|
return (0, _promises.rm)(r);
|
|
16
16
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as o,rmSync as e}from"node:fs";import{rm as i}from"node:fs/promises";export const removeFileSync=r=>{if(!r||!o(r))throw new Error("Invalid file path provided to remove data");e(r)},removeFile=r=>{if(!r||!o(r))throw new Error("Invalid file path provided to remove data");return i(r)};
|
|
1
|
+
import{existsSync as o,rmSync as e}from"node:fs";import{rm as i}from"node:fs/promises";export const removeFileSync=r=>{if(!r||!o(r))throw new Error("Invalid file path provided to remove data");e(r)},removeFile=async r=>{if(!r||!o(r))throw new Error("Invalid file path provided to remove data");return i(r)};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stryke/fs",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing various file system utilities that expand the functionality of NodeJs's `fs` module.",
|
|
6
6
|
"repository": {
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"chalk": "^5.4.1",
|
|
18
18
|
"nanotar": "^0.2.0",
|
|
19
19
|
"semver": "7.7.1",
|
|
20
|
-
"@stryke/json": ">=0.4.
|
|
21
|
-
"@stryke/path": ">=0.3.
|
|
22
|
-
"@stryke/types": ">=0.5.
|
|
20
|
+
"@stryke/json": ">=0.4.2",
|
|
21
|
+
"@stryke/path": ">=0.3.1",
|
|
22
|
+
"@stryke/types": ">=0.5.1"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/node": "^22.13.1",
|