@stryke/fs 0.3.0 → 0.5.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/files/helpers.cjs +8 -8
- package/dist/files/helpers.mjs +1 -1
- package/dist/files/index.cjs +11 -0
- package/dist/files/index.d.ts +1 -0
- package/dist/files/index.mjs +1 -1
- package/dist/files/list-files.cjs +20 -0
- package/dist/files/list-files.d.ts +7 -0
- package/dist/files/list-files.mjs +1 -0
- package/dist/files/write-file.cjs +2 -2
- package/dist/files/write-file.mjs +2 -2
- package/package.json +17 -3
package/dist/files/helpers.cjs
CHANGED
|
@@ -7,10 +7,10 @@ exports.createDirectory = createDirectory;
|
|
|
7
7
|
exports.createDirectorySync = createDirectorySync;
|
|
8
8
|
exports.extractFileFromTar = extractFileFromTar;
|
|
9
9
|
exports.extractFileFromTarGzip = extractFileFromTarGzip;
|
|
10
|
-
var _exists = require("@stryke/path/utilities/exists");
|
|
11
|
-
var _nanotar = require("nanotar");
|
|
12
10
|
var _nodeFs = require("node:fs");
|
|
13
11
|
var _promises = require("node:fs/promises");
|
|
12
|
+
var _exists = require("@stryke/path/utilities/exists");
|
|
13
|
+
var _nanotar = require("nanotar");
|
|
14
14
|
function createDirectorySync(r) {
|
|
15
15
|
if (!(0, _exists.existsSync)(r)) return (0, _nodeFs.mkdirSync)(r, {
|
|
16
16
|
recursive: !0
|
|
@@ -21,17 +21,17 @@ async function createDirectory(r) {
|
|
|
21
21
|
recursive: !0
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
async function extractFileFromTar(r,
|
|
25
|
-
const e = (0, _nanotar.parseTar)(await (0, _promises.readFile)(r)).find(
|
|
24
|
+
async function extractFileFromTar(r, i, t) {
|
|
25
|
+
const e = (0, _nanotar.parseTar)(await (0, _promises.readFile)(r)).find(a => a.name === i);
|
|
26
26
|
if (!e?.data) return;
|
|
27
27
|
(await (0, _exists.exists)(t)) || (await (0, _promises.mkdir)(t, {
|
|
28
28
|
recursive: !0
|
|
29
|
-
})),
|
|
29
|
+
})), (0, _nodeFs.createWriteStream)(t).write(e.data);
|
|
30
30
|
}
|
|
31
|
-
async function extractFileFromTarGzip(r,
|
|
32
|
-
const e = (await (0, _nanotar.parseTarGzip)(await (0, _promises.readFile)(r))).find(
|
|
31
|
+
async function extractFileFromTarGzip(r, i, t) {
|
|
32
|
+
const e = (await (0, _nanotar.parseTarGzip)(await (0, _promises.readFile)(r))).find(a => a.name === i);
|
|
33
33
|
if (!e?.data) return;
|
|
34
34
|
(await (0, _exists.exists)(t)) || (await (0, _promises.mkdir)(t, {
|
|
35
35
|
recursive: !0
|
|
36
|
-
})),
|
|
36
|
+
})), (0, _nodeFs.createWriteStream)(t).write(e.data);
|
|
37
37
|
}
|
package/dist/files/helpers.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{createWriteStream as c,mkdirSync as f}from"node:fs";import{mkdir as n,readFile as o}from"node:fs/promises";import{exists as s,existsSync as p}from"@stryke/path/utilities/exists";import{parseTar as w,parseTarGzip as y}from"nanotar";export function createDirectorySync(r){if(!p(r))return f(r,{recursive:!0})}export async function createDirectory(r){if(!await s(r))return n(r,{recursive:!0})}export async function extractFileFromTar(r,i,t){const e=w(await o(r)).find(a=>a.name===i);if(!e?.data)return;await s(t)||await n(t,{recursive:!0}),c(t).write(e.data)}export async function extractFileFromTarGzip(r,i,t){const e=(await y(await o(r))).find(a=>a.name===i);if(!e?.data)return;await s(t)||await n(t,{recursive:!0}),c(t).write(e.data)}
|
package/dist/files/index.cjs
CHANGED
|
@@ -47,6 +47,17 @@ Object.keys(_helpers).forEach(function (key) {
|
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
49
|
});
|
|
50
|
+
var _listFiles = require("./list-files.cjs");
|
|
51
|
+
Object.keys(_listFiles).forEach(function (key) {
|
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
|
53
|
+
if (key in exports && exports[key] === _listFiles[key]) return;
|
|
54
|
+
Object.defineProperty(exports, key, {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _listFiles[key];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
50
61
|
var _readFile = require("./read-file.cjs");
|
|
51
62
|
Object.keys(_readFile).forEach(function (key) {
|
|
52
63
|
if (key === "default" || key === "__esModule") return;
|
package/dist/files/index.d.ts
CHANGED
package/dist/files/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./chmod-x";export*from"./constants";export*from"./copy-files";export*from"./helpers";export*from"./read-file";export*from"./remove-file";export*from"./write-file";
|
|
1
|
+
export*from"./chmod-x";export*from"./constants";export*from"./copy-files";export*from"./helpers";export*from"./list-files";export*from"./read-file";export*from"./remove-file";export*from"./write-file";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.listFiles = listFiles;
|
|
7
|
+
var _promises = require("node:fs/promises");
|
|
8
|
+
var _isFile = require("@stryke/path/utilities/is-file");
|
|
9
|
+
var _joinPaths = require("@stryke/path/utilities/join-paths");
|
|
10
|
+
async function listFiles(a) {
|
|
11
|
+
const s = [],
|
|
12
|
+
t = async r => {
|
|
13
|
+
const n = await (0, _promises.readdir)(r);
|
|
14
|
+
await Promise.all(n.map(async o => {
|
|
15
|
+
const i = (0, _joinPaths.joinPaths)(r, o);
|
|
16
|
+
(0, _isFile.isDirectory)(i) ? await t(i) : s.push(i);
|
|
17
|
+
}));
|
|
18
|
+
};
|
|
19
|
+
return await t(a), s;
|
|
20
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The file listing library used by Storm Software for building TypeScript applications.
|
|
3
|
+
*
|
|
4
|
+
* @param directoryPath - The directory path to list files from
|
|
5
|
+
* @returns A list of file paths
|
|
6
|
+
*/
|
|
7
|
+
export declare function listFiles(directoryPath: string): Promise<string[]>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readdir as e}from"node:fs/promises";import{isDirectory as m}from"@stryke/path/utilities/is-file";import{joinPaths as c}from"@stryke/path/utilities/join-paths";export async function listFiles(a){const s=[],t=async r=>{const n=await e(r);await Promise.all(n.map(async o=>{const i=c(r,o);m(i)?await t(i):s.push(i)}))};return await t(a),s}
|
|
@@ -20,12 +20,12 @@ const writeFileSync = (e, o, n) => {
|
|
|
20
20
|
exports.writeFile = writeFile;
|
|
21
21
|
exports.writeFileSync = writeFileSync;
|
|
22
22
|
function writeJsonFileSync(e, o, n) {
|
|
23
|
-
const i = _stormJson.StormJSON.
|
|
23
|
+
const i = _stormJson.StormJSON.stringify(o, n);
|
|
24
24
|
return writeFileSync(e, n?.appendNewLine ? `${i}
|
|
25
25
|
` : i);
|
|
26
26
|
}
|
|
27
27
|
async function writeJsonFile(e, o, n) {
|
|
28
|
-
const i = _stormJson.StormJSON.
|
|
28
|
+
const i = _stormJson.StormJSON.stringify(o);
|
|
29
29
|
return writeFile(e, n?.appendNewLine ? `${i}
|
|
30
30
|
` : i);
|
|
31
31
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{writeFileSync as r}from"node:fs";import{writeFile as s}from"node:fs/promises";import{StormJSON as t}from"@stryke/json/storm-json";export const writeFileSync=(e,o,n)=>{if(!e)throw new Error("No file path provided to write data");r(e,o||"",n)},writeFile=async(e,o,n)=>{if(!e)throw new Error("No file path provided to read data");return s(e,o||"",n)};export function writeJsonFileSync(e,o,n){const i=t.
|
|
2
|
-
`:i)}export async function writeJsonFile(e,o,n){const i=t.
|
|
1
|
+
import{writeFileSync as r}from"node:fs";import{writeFile as s}from"node:fs/promises";import{StormJSON as t}from"@stryke/json/storm-json";export const writeFileSync=(e,o,n)=>{if(!e)throw new Error("No file path provided to write data");r(e,o||"",n)},writeFile=async(e,o,n)=>{if(!e)throw new Error("No file path provided to read data");return s(e,o||"",n)};export function writeJsonFileSync(e,o,n){const i=t.stringify(o,n);return writeFileSync(e,n?.appendNewLine?`${i}
|
|
2
|
+
`:i)}export async function writeJsonFile(e,o,n){const i=t.stringify(o);return writeFile(e,n?.appendNewLine?`${i}
|
|
3
3
|
`:i)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stryke/fs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
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,8 +17,8 @@
|
|
|
17
17
|
"chalk": "^5.4.1",
|
|
18
18
|
"nanotar": "^0.2.0",
|
|
19
19
|
"semver": "7.7.1",
|
|
20
|
-
"@stryke/json": ">=0.
|
|
21
|
-
"@stryke/path": ">=0.
|
|
20
|
+
"@stryke/json": ">=0.4.1",
|
|
21
|
+
"@stryke/path": ">=0.3.0",
|
|
22
22
|
"@stryke/types": ">=0.5.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
@@ -191,6 +191,20 @@
|
|
|
191
191
|
"default": "./dist/files/read-file.mjs"
|
|
192
192
|
}
|
|
193
193
|
},
|
|
194
|
+
"./files/list-files": {
|
|
195
|
+
"import": {
|
|
196
|
+
"types": "./dist/files/list-files.d.ts",
|
|
197
|
+
"default": "./dist/files/list-files.mjs"
|
|
198
|
+
},
|
|
199
|
+
"require": {
|
|
200
|
+
"types": "./dist/files/list-files.d.ts",
|
|
201
|
+
"default": "./dist/files/list-files.cjs"
|
|
202
|
+
},
|
|
203
|
+
"default": {
|
|
204
|
+
"types": "./dist/files/list-files.d.ts",
|
|
205
|
+
"default": "./dist/files/list-files.mjs"
|
|
206
|
+
}
|
|
207
|
+
},
|
|
194
208
|
"./files/index": {
|
|
195
209
|
"import": {
|
|
196
210
|
"types": "./dist/files/index.d.ts",
|