UNPKG

@licq/nwjs-minidump

Version:

decode a nwjs crashed dump file

73 lines (68 loc) 1.96 kB
#!/usr/bin/env node const fs = require("fs"); const program = require("commander"); const semver = require("semver"); const dumpUtils = require("./index"); const version = require("./package.json").version; program.version(version); program .command("decode") .description("decode a nwjs dump file") .requiredOption( "-f, --dumpFile <path>", "path of the .dmp file", function (value) { // if (!fs.existsSync(value) || !value.endsWith(".dmp")) { // throw new program.InvalidArgumentError( // "Dumpfile does not exist or does not end with .dmp ." // ); // } return value; } ) .requiredOption( "-v, --nwVersion <semver>", "nwjs version eg: 0.57.1|0.57.1-sdk. see <https://dl.nwjs.io/>", function (value) { if (!semver.valid(value)) { throw new program.InvalidArgumentError( "nwjs version should conform to semver specification, see <https://dl.nwjs.io/>." ); } return value; } ) .option( "-s, --symbolsPath <path>", "path of the symbols. If this parameter is not specified, it will be downloaded by default", function (value) { if (value && !fs.existsSync(value)) { throw new program.InvalidArgumentError("symbols dir not exist."); } return value; } ) .option( "-o, --output <path>", "path of the output. The default value is the same as the .dmp file", function (value) { if (value && !fs.existsSync(value)) { throw new program.InvalidArgumentError("output dir not exist."); } return value; } ) .action(async ({ dumpFile, nwVersion, symbolsPath, output }) => { try { const res = await dumpUtils.decodeDmp({ dumpFile, nwVersion, output, symbolsPath, }); console.log("\n", res); } catch (e) { console.log("\ndecodeDmp error: " + e.message); } }); program.parse();