@stryke/fs 0.10.7 → 0.11.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/install.cjs CHANGED
@@ -11,11 +11,11 @@ const install = async (t, a) => (0, _installPkg.installPackage)(t, a),
11
11
  packageExists = async (t, a) => {
12
12
  const r = await (0, _resolve.resolve)(a?.cwd || process.cwd());
13
13
  try {
14
- (0, _resolve.resolve)(t, {
14
+ await (0, _resolve.resolve)(t, {
15
15
  paths: [r]
16
16
  });
17
17
  } catch {
18
- install(t, a);
18
+ await install(t, a);
19
19
  }
20
20
  };
21
21
  exports.packageExists = packageExists;
package/dist/install.mjs CHANGED
@@ -1 +1 @@
1
- import{installPackage as n}from"@antfu/install-pkg";import{resolve as s}from"@stryke/path/resolve";import"tinyexec";export const install=async(t,a)=>n(t,a),packageExists=async(t,a)=>{const r=await s(a?.cwd||process.cwd());try{s(t,{paths:[r]})}catch{install(t,a)}};
1
+ import{installPackage as n}from"@antfu/install-pkg";import{resolve as s}from"@stryke/path/resolve";import"tinyexec";export const install=async(t,a)=>n(t,a),packageExists=async(t,a)=>{const r=await s(a?.cwd||process.cwd());try{await s(t,{paths:[r]})}catch{await install(t,a)}};
@@ -9,19 +9,16 @@ var _joinPaths = require("@stryke/path/join-paths");
9
9
  var _promises = require("node:fs/promises");
10
10
  var _picomatch = _interopRequireDefault(require("picomatch"));
11
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- async function listFiles(e, a = {}) {
13
- const {
14
- ignored: t = []
15
- } = a,
16
- r = [],
17
- n = async s => {
18
- if (!(0, _picomatch.default)(s, t)) {
19
- const c = await (0, _promises.readdir)(s);
20
- await Promise.all(c.map(async f => {
21
- const i = (0, _joinPaths.joinPaths)(s, f);
22
- (0, _picomatch.default)(i, t) || ((0, _isFile.isDirectory)(i) ? await n(i) : r.push(i));
12
+ async function listFiles(e, s = {}) {
13
+ const o = [],
14
+ r = async t => {
15
+ if (!(0, _picomatch.default)(t, s)) {
16
+ const n = await (0, _promises.readdir)(t);
17
+ await Promise.all(n.map(async m => {
18
+ const i = (0, _joinPaths.joinPaths)(t, m);
19
+ (0, _picomatch.default)(i, s) || ((0, _isFile.isDirectory)(i) ? await r(i) : o.push(i));
23
20
  }));
24
21
  }
25
22
  };
26
- return await n(e), r;
23
+ return await r(e), o;
27
24
  }
@@ -1,11 +1,5 @@
1
- export interface ListFilesOptions {
2
- /**
3
- * A list of directories/files to ignore
4
- *
5
- * @defaultValue []
6
- */
7
- ignored?: string[];
8
- }
1
+ import type { PicomatchOptions } from "picomatch";
2
+ export type ListFilesOptions = PicomatchOptions;
9
3
  /**
10
4
  * The file listing library used by Storm Software for building TypeScript applications.
11
5
  *
@@ -1 +1 @@
1
- import{isDirectory as m}from"@stryke/path/is-file";import{joinPaths as l}from"@stryke/path/join-paths";import{readdir as p}from"node:fs/promises";import o from"picomatch";export async function listFiles(e,a={}){const{ignored:t=[]}=a,r=[],n=async s=>{if(!o(s,t)){const c=await p(s);await Promise.all(c.map(async f=>{const i=l(s,f);o(i,t)||(m(i)?await n(i):r.push(i))}))}};return await n(e),r}
1
+ import{isDirectory as c}from"@stryke/path/is-file";import{joinPaths as p}from"@stryke/path/join-paths";import{readdir as f}from"node:fs/promises";import a from"picomatch";export async function listFiles(e,s={}){const o=[],r=async t=>{if(!a(t,s)){const n=await f(t);await Promise.all(n.map(async m=>{const i=p(t,m);a(i,s)||(c(i)?await r(i):o.push(i))}))}};return await r(e),o}
@@ -13,13 +13,13 @@ var _filePathFns = require("@stryke/path/file-path-fns");
13
13
  var _nodeFs = require("node:fs");
14
14
  var _promises = require("node:fs/promises");
15
15
  var _helpers = require("./helpers.cjs");
16
- const writeFileSync = (r, o, t = {}) => {
16
+ const writeFileSync = (r, o = "", t = {}) => {
17
17
  if (!r) throw new Error("No file path provided to write data");
18
18
  const e = (0, _filePathFns.findFilePath)((0, _correctPath.correctPath)(r));
19
19
  if (!(0, _exists.existsSync)(e)) if (t.createDirectory !== !1) (0, _helpers.createDirectorySync)(e);else throw new Error(`Directory ${e} does not exist`);
20
20
  (0, _nodeFs.writeFileSync)(r, o || "", t);
21
21
  },
22
- writeFile = async (r, o, t = {}) => {
22
+ writeFile = async (r, o = "", t = {}) => {
23
23
  if (!r) throw new Error("No file path provided to read data");
24
24
  const e = (0, _filePathFns.findFilePath)((0, _correctPath.correctPath)(r));
25
25
  if (!(0, _exists.existsSync)(e)) if (t.createDirectory !== !1) await (0, _helpers.createDirectory)(e);else throw new Error(`Directory ${e} does not exist`);
@@ -16,7 +16,7 @@ export interface WriteFileOptions {
16
16
  * @param filePath - The file path to write to
17
17
  * @param content - The content to write to the file
18
18
  */
19
- export declare const writeFileSync: (filePath: string, content?: any, options?: WriteFileOptions & FSWriteFileOptions) => void;
19
+ export declare const writeFileSync: (filePath: string, content?: string, options?: WriteFileOptions & FSWriteFileOptions) => void;
20
20
  /**
21
21
  * Read the given content to the given file path
22
22
  *
@@ -24,7 +24,7 @@ export declare const writeFileSync: (filePath: string, content?: any, options?:
24
24
  * @param content - The content to write to the file
25
25
  * @returns The content of the file
26
26
  */
27
- export declare const writeFile: (filePath: string, content?: any, options?: WriteFileOptions & ((ObjectEncodingOptions & {
27
+ export declare const writeFile: (filePath: string, content?: string, options?: WriteFileOptions & ((ObjectEncodingOptions & {
28
28
  mode?: Mode | undefined;
29
29
  flag?: OpenMode | undefined;
30
30
  flush?: boolean | undefined;
@@ -1,3 +1,3 @@
1
- import{StormJSON as i}from"@stryke/json/storm-json";import{correctPath as n}from"@stryke/path/correct-path";import{existsSync as s}from"@stryke/path/exists";import{findFilePath as c}from"@stryke/path/file-path-fns";import{writeFileSync as p}from"node:fs";import{writeFile as d}from"node:fs/promises";import{createDirectory as a,createDirectorySync as f}from"./helpers";export const writeFileSync=(r,o,t={})=>{if(!r)throw new Error("No file path provided to write data");const e=c(n(r));if(!s(e))if(t.createDirectory!==!1)f(e);else throw new Error(`Directory ${e} does not exist`);p(r,o||"",t)},writeFile=async(r,o,t={})=>{if(!r)throw new Error("No file path provided to read data");const e=c(n(r));if(!s(e))if(t.createDirectory!==!1)await a(e);else throw new Error(`Directory ${e} does not exist`);return d(r,o||"",t)};export function writeJsonFileSync(r,o,t){const e=i.stringify(o,t);return writeFileSync(r,t?.appendNewLine?`${e}
1
+ import{StormJSON as i}from"@stryke/json/storm-json";import{correctPath as n}from"@stryke/path/correct-path";import{existsSync as s}from"@stryke/path/exists";import{findFilePath as c}from"@stryke/path/file-path-fns";import{writeFileSync as p}from"node:fs";import{writeFile as d}from"node:fs/promises";import{createDirectory as a,createDirectorySync as f}from"./helpers";export const writeFileSync=(r,o="",t={})=>{if(!r)throw new Error("No file path provided to write data");const e=c(n(r));if(!s(e))if(t.createDirectory!==!1)f(e);else throw new Error(`Directory ${e} does not exist`);p(r,o||"",t)},writeFile=async(r,o="",t={})=>{if(!r)throw new Error("No file path provided to read data");const e=c(n(r));if(!s(e))if(t.createDirectory!==!1)await a(e);else throw new Error(`Directory ${e} does not exist`);return d(r,o||"",t)};export function writeJsonFileSync(r,o,t){const e=i.stringify(o,t);return writeFileSync(r,t?.appendNewLine?`${e}
2
2
  `:e)}export async function writeJsonFile(r,o,t){const e=i.stringify(o);return writeFile(r,t?.appendNewLine?`${e}
3
3
  `:e)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/fs",
3
- "version": "0.10.7",
3
+ "version": "0.11.1",
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": {
@@ -18,10 +18,10 @@
18
18
  "nanotar": "^0.2.0",
19
19
  "picomatch": "^4.0.2",
20
20
  "semver": "7.7.1",
21
- "@stryke/json": "^0.5.4",
21
+ "@stryke/json": "^0.7.0",
22
22
  "@stryke/path": "^0.4.7",
23
- "@stryke/type-checks": "^0.1.4",
24
- "@stryke/types": "^0.7.4"
23
+ "@stryke/type-checks": "^0.3.0",
24
+ "@stryke/types": "^0.8.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/node": "^22.13.1",