@ark/fs 0.1.2 → 0.2.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/out/fs.d.ts +4 -1
- package/out/fs.js +20 -2
- package/out/getCurrentLine.js +1 -1
- package/package.json +1 -1
package/out/fs.d.ts
CHANGED
|
@@ -25,7 +25,10 @@ export declare const fromHere: (...joinWith: string[]) => string;
|
|
|
25
25
|
export declare const fromCwd: (...joinWith: string[]) => string;
|
|
26
26
|
export declare const fromHome: (...joinWith: string[]) => string;
|
|
27
27
|
export declare const fsRoot: string;
|
|
28
|
-
export declare const findPackageRoot: (fromDir?: string) => string;
|
|
28
|
+
export declare const findPackageRoot: (fromDir?: string) => string | null;
|
|
29
|
+
export declare const assertPackageRoot: (fromDir?: string) => string;
|
|
30
|
+
export declare const findPackageAncestors: (fromDir?: string) => string[];
|
|
31
|
+
export declare const readPackageJsonAncestors: (fromDir?: string) => any[];
|
|
29
32
|
export declare const fromPackageRoot: (...joinWith: string[]) => string;
|
|
30
33
|
export declare const readPackageJson: (startDir?: string) => any;
|
|
31
34
|
export declare const getSourceControlPaths: () => string[];
|
package/out/fs.js
CHANGED
|
@@ -78,10 +78,28 @@ export const findPackageRoot = (fromDir) => {
|
|
|
78
78
|
}
|
|
79
79
|
dirToCheck = join(dirToCheck, "..");
|
|
80
80
|
}
|
|
81
|
+
return null;
|
|
82
|
+
};
|
|
83
|
+
export const assertPackageRoot = (fromDir) => {
|
|
84
|
+
const startDir = fromDir ?? dirOfCaller();
|
|
85
|
+
const result = findPackageRoot(fromDir);
|
|
86
|
+
if (result)
|
|
87
|
+
return result;
|
|
81
88
|
throw new Error(`${startDir} is not part of a node package.`);
|
|
82
89
|
};
|
|
83
|
-
export const
|
|
84
|
-
|
|
90
|
+
export const findPackageAncestors = (fromDir) => {
|
|
91
|
+
const dirs = [];
|
|
92
|
+
let dir = fromDir ?? dirOfCaller();
|
|
93
|
+
while (dir) {
|
|
94
|
+
dir = findPackageRoot(dir);
|
|
95
|
+
if (dir)
|
|
96
|
+
dirs.push(dir);
|
|
97
|
+
}
|
|
98
|
+
return dirs;
|
|
99
|
+
};
|
|
100
|
+
export const readPackageJsonAncestors = (fromDir) => findPackageAncestors(fromDir).map(dir => readPackageJson(dir));
|
|
101
|
+
export const fromPackageRoot = (...joinWith) => join(assertPackageRoot(dirOfCaller()), ...joinWith);
|
|
102
|
+
export const readPackageJson = (startDir) => readJson(join(assertPackageRoot(startDir), "package.json"));
|
|
85
103
|
export const getSourceControlPaths = () =>
|
|
86
104
|
// include tracked and untracked files as long as they are not ignored
|
|
87
105
|
getShellOutput("git ls-files --exclude-standard --cached --others")
|
package/out/getCurrentLine.js
CHANGED
|
@@ -12,7 +12,7 @@ export const getFramesFromError = (error) => {
|
|
|
12
12
|
}
|
|
13
13
|
catch (error1) {
|
|
14
14
|
try {
|
|
15
|
-
|
|
15
|
+
// @ts-expect-error https://github.com/winstonjs/winston/issues/401#issuecomment-61913086
|
|
16
16
|
const previous = err.__previous__ || err.__previous;
|
|
17
17
|
stack = previous && previous.stack;
|
|
18
18
|
}
|