dep-brain 0.5.1 → 0.5.2
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/cli.js +7 -2
- package/dist/utils/path.js +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -48,7 +48,8 @@ async function main() {
|
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
50
|
try {
|
|
51
|
-
const
|
|
51
|
+
const resolvedFrom = resolveUserPath(fromPath);
|
|
52
|
+
const raw = await fs.readFile(resolvedFrom, "utf8");
|
|
52
53
|
const reportData = JSON.parse(raw);
|
|
53
54
|
const output = flags.has("--json")
|
|
54
55
|
? JSON.stringify(reportData, null, 2)
|
|
@@ -205,7 +206,8 @@ async function loadPackageVersion() {
|
|
|
205
206
|
}
|
|
206
207
|
async function writeOutput(output, outPath) {
|
|
207
208
|
if (outPath) {
|
|
208
|
-
|
|
209
|
+
const resolved = resolveUserPath(outPath);
|
|
210
|
+
await fs.writeFile(resolved, `${output}\n`, "utf8");
|
|
209
211
|
return;
|
|
210
212
|
}
|
|
211
213
|
process.stdout.write(`${output}\n`);
|
|
@@ -213,3 +215,6 @@ async function writeOutput(output, outPath) {
|
|
|
213
215
|
function sanitizeForLog(value) {
|
|
214
216
|
return value.replace(/[\r\n]+/g, " ").trim();
|
|
215
217
|
}
|
|
218
|
+
function resolveUserPath(value) {
|
|
219
|
+
return path.resolve(process.cwd(), value);
|
|
220
|
+
}
|
package/dist/utils/path.js
CHANGED
|
@@ -3,7 +3,7 @@ export function resolveWithinRoot(rootDir, targetPath) {
|
|
|
3
3
|
const resolvedRoot = path.resolve(rootDir);
|
|
4
4
|
const resolvedTarget = path.resolve(resolvedRoot, targetPath);
|
|
5
5
|
if (!isWithinRoot(resolvedRoot, resolvedTarget)) {
|
|
6
|
-
throw new Error(`Path is
|
|
6
|
+
throw new Error(`Path is outside root: ${resolvedTarget}`);
|
|
7
7
|
}
|
|
8
8
|
return resolvedTarget;
|
|
9
9
|
}
|