@stryke/fs 0.10.5 → 0.10.7
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/package-fns.cjs +14 -14
- package/dist/package-fns.d.ts +2 -2
- package/dist/package-fns.mjs +1 -1
- package/dist/write-file.cjs +4 -4
- package/dist/write-file.mjs +1 -1
- package/package.json +5 -5
package/dist/package-fns.cjs
CHANGED
|
@@ -16,20 +16,20 @@ var _getWorkspaceRoot = require("@stryke/path/get-workspace-root");
|
|
|
16
16
|
var _resolve = require("@stryke/path/resolve");
|
|
17
17
|
var _readFile = require("./read-file.cjs");
|
|
18
18
|
function getPackageManager(a = (0, _getWorkspaceRoot.getWorkspaceRoot)()) {
|
|
19
|
-
const e = (0, _getParentPath.getParentPath)([
|
|
20
|
-
if (!e) return
|
|
19
|
+
const e = (0, _getParentPath.getParentPath)(["package-lock.json", "yarn.lock", "pnpm-lock.yaml", "bun.lock"], a);
|
|
20
|
+
if (!e) return "pnpm";
|
|
21
21
|
switch ((0, _path.findFileName)(e)) {
|
|
22
|
-
case
|
|
23
|
-
return
|
|
24
|
-
case
|
|
25
|
-
return
|
|
26
|
-
case
|
|
27
|
-
return
|
|
22
|
+
case "yarn.lock":
|
|
23
|
+
return "yarn";
|
|
24
|
+
case "pnpm-lock.yaml":
|
|
25
|
+
return "pnpm";
|
|
26
|
+
case "bun.lock":
|
|
27
|
+
return "bun";
|
|
28
28
|
default:
|
|
29
|
-
return
|
|
29
|
+
return "npm";
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
async function
|
|
32
|
+
async function f(a) {
|
|
33
33
|
let e;
|
|
34
34
|
for (;;) {
|
|
35
35
|
if (!a) return;
|
|
@@ -39,12 +39,12 @@ async function l(a) {
|
|
|
39
39
|
}
|
|
40
40
|
return e;
|
|
41
41
|
}
|
|
42
|
-
async function
|
|
42
|
+
async function k(a, e = {}) {
|
|
43
43
|
const n = await (0, _resolve.resolvePackage)(a, e);
|
|
44
|
-
if (n) return
|
|
44
|
+
if (n) return f(n);
|
|
45
45
|
}
|
|
46
46
|
async function getPackageInfo(a, e = {}) {
|
|
47
|
-
const n = await
|
|
47
|
+
const n = await k(a, e);
|
|
48
48
|
if (!n) return;
|
|
49
49
|
const t = _stormJson.StormJSON.parse(await (0, _readFile.readFile)(n));
|
|
50
50
|
return {
|
|
@@ -56,7 +56,7 @@ async function getPackageInfo(a, e = {}) {
|
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
58
|
async function getPackageInfoSync(a, e = {}) {
|
|
59
|
-
const n = await
|
|
59
|
+
const n = await k(a, e);
|
|
60
60
|
if (!n) return;
|
|
61
61
|
const t = _stormJson.StormJSON.parse(await (0, _readFile.readFile)(n));
|
|
62
62
|
return {
|
package/dist/package-fns.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { PackageResolvingOptions } from "@stryke/path/resolve";
|
|
2
2
|
import type { PackageJson } from "@stryke/types/package-json";
|
|
3
|
-
import type {
|
|
3
|
+
import type { PackageManager } from "@stryke/types/package-manager";
|
|
4
4
|
/**
|
|
5
5
|
* Get the package manager used in the project
|
|
6
6
|
* @param dir - The path to the project
|
|
7
7
|
* @returns The package manager used in the project
|
|
8
8
|
*/
|
|
9
|
-
export declare function getPackageManager(dir?: any):
|
|
9
|
+
export declare function getPackageManager(dir?: any): PackageManager;
|
|
10
10
|
/**
|
|
11
11
|
* Get package info
|
|
12
12
|
*
|
package/dist/package-fns.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{StormJSON as
|
|
1
|
+
import{StormJSON as o}from"@stryke/json/storm-json";import{exists as i,findFileName as u,findFilePath as r,joinPaths as P}from"@stryke/path";import{getParentPath as c}from"@stryke/path/get-parent-path";import{getWorkspaceRoot as g}from"@stryke/path/get-workspace-root";import{resolvePackage as p}from"@stryke/path/resolve";import{readFile as s}from"./read-file";export function getPackageManager(a=g()){const e=c(["package-lock.json","yarn.lock","pnpm-lock.yaml","bun.lock"],a);if(!e)return"pnpm";switch(u(e)){case"yarn.lock":return"yarn";case"pnpm-lock.yaml":return"pnpm";case"bun.lock":return"bun";default:return"npm"}}async function f(a){let e;for(;;){if(!a)return;const n=r(a);if(n===a)return;if(a=n,e=P(a,"package.json"),await i(e))break}return e}async function k(a,e={}){const n=await p(a,e);if(n)return f(n)}export async function getPackageInfo(a,e={}){const n=await k(a,e);if(!n)return;const t=o.parse(await s(n));return{name:a,version:t.version,rootPath:r(n),packageJsonPath:n,packageJson:t}}export async function getPackageInfoSync(a,e={}){const n=await k(a,e);if(!n)return;const t=o.parse(await s(n));return{name:a,version:t.version,rootPath:r(n),packageJsonPath:n,packageJson:t}}export async function loadPackageJSON(a=g()){const e=c("package.json",a,{skipCwd:!1});return!e||!await i(e)?null:o.parse(await s(e))}export async function isPackageListed(a,e){const n=await loadPackageJSON(e)??{};return a in(n.dependencies??{})||a in(n.devDependencies??{})}export function isPackageExists(a,e={}){return!!p(a,e)}
|
package/dist/write-file.cjs
CHANGED
|
@@ -13,16 +13,16 @@ 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
|
-
if (!(0, _exists.existsSync)(e)) if (t
|
|
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
|
-
if (!(0, _exists.existsSync)(e)) if (t
|
|
25
|
+
if (!(0, _exists.existsSync)(e)) if (t.createDirectory !== !1) await (0, _helpers.createDirectory)(e);else throw new Error(`Directory ${e} does not exist`);
|
|
26
26
|
return (0, _promises.writeFile)(r, o || "", t);
|
|
27
27
|
};
|
|
28
28
|
exports.writeFile = writeFile;
|
package/dist/write-file.mjs
CHANGED
|
@@ -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
|
|
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.
|
|
3
|
+
"version": "0.10.7",
|
|
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": "
|
|
22
|
-
"@stryke/path": "
|
|
23
|
-
"@stryke/type-checks": "
|
|
24
|
-
"@stryke/types": "
|
|
21
|
+
"@stryke/json": "^0.5.4",
|
|
22
|
+
"@stryke/path": "^0.4.7",
|
|
23
|
+
"@stryke/type-checks": "^0.1.4",
|
|
24
|
+
"@stryke/types": "^0.7.4"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "^22.13.1",
|