logshield-cli 0.2.1 → 0.2.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/index.cjs +15 -3
- package/package.json +1 -1
package/dist/cli/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
#!/usr/bin/env node
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
@@ -347,14 +347,26 @@ var init_sanitizeLog = __esm({
|
|
|
347
347
|
});
|
|
348
348
|
|
|
349
349
|
// src/cli/index.ts
|
|
350
|
+
var import_fs = require("fs");
|
|
351
|
+
var import_path = __toESM(require("path"));
|
|
350
352
|
var { readInput: readInput2 } = (init_readInput(), __toCommonJS(readInput_exports));
|
|
351
353
|
var { writeOutput: writeOutput2 } = (init_writeOutput(), __toCommonJS(writeOutput_exports));
|
|
352
354
|
var { printSummary: printSummary2 } = (init_summary(), __toCommonJS(summary_exports));
|
|
353
355
|
var { sanitizeLog: sanitizeLog2 } = (init_sanitizeLog(), __toCommonJS(sanitizeLog_exports));
|
|
356
|
+
var __dirname = import_path.default.dirname(process.argv[1]);
|
|
354
357
|
var args = process.argv.slice(2);
|
|
355
358
|
function hasFlag(flag) {
|
|
356
359
|
return args.includes(flag);
|
|
357
360
|
}
|
|
361
|
+
function getVersion() {
|
|
362
|
+
try {
|
|
363
|
+
const pkgPath = import_path.default.resolve(__dirname, "../../package.json");
|
|
364
|
+
const pkg = JSON.parse((0, import_fs.readFileSync)(pkgPath, "utf8"));
|
|
365
|
+
return pkg.version;
|
|
366
|
+
} catch {
|
|
367
|
+
return "unknown";
|
|
368
|
+
}
|
|
369
|
+
}
|
|
358
370
|
function getFileArg() {
|
|
359
371
|
const file = args[1];
|
|
360
372
|
if (!file || file.startsWith("--")) return void 0;
|
|
@@ -374,7 +386,7 @@ Options:
|
|
|
374
386
|
process.exit(0);
|
|
375
387
|
}
|
|
376
388
|
if (hasFlag("--version")) {
|
|
377
|
-
|
|
389
|
+
console.log(`logshield v${getVersion()}`);
|
|
378
390
|
process.exit(0);
|
|
379
391
|
}
|
|
380
392
|
const command = args[0];
|
|
@@ -394,7 +406,7 @@ Options:
|
|
|
394
406
|
printSummary2(result.matches);
|
|
395
407
|
}
|
|
396
408
|
} catch (err) {
|
|
397
|
-
process.stderr.write(err
|
|
409
|
+
process.stderr.write(err?.message || "Unexpected error");
|
|
398
410
|
process.stderr.write("\n");
|
|
399
411
|
process.exit(2);
|
|
400
412
|
}
|