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