snyk
Version:
snyk library and cli utility
46 lines (40 loc) • 1.42 kB
JavaScript
;
exports.id = 862;
exports.ids = [862];
exports.modules = {
/***/ 97862:
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
Object.defineProperty(exports, "__esModule", ({ value: true }));
const fs = __webpack_require__(35747);
const path = __webpack_require__(85622);
const strip_ansi_1 = __webpack_require__(76003);
const DEFAULT_HELP = 'snyk';
function readHelpFile(filename) {
const file = fs.readFileSync(filename, 'utf8');
if (typeof process.env.NO_COLOR !== 'undefined' || !process.stdout.isTTY) {
return strip_ansi_1.default(file);
}
return file;
}
async function help(item) {
if (!item || item === true || typeof item !== 'string' || item === 'help') {
item = DEFAULT_HELP;
}
// cleanse the filename to only contain letters
// aka: /\W/g but figured this was easier to read
item = item.replace(/[^a-z-]/gi, '');
try {
const filename = path.resolve(__dirname, '../../help/commands-txt', // this is a relative path from the webpack dist directory
item === DEFAULT_HELP ? `${DEFAULT_HELP}.txt` : `snyk-${item}.txt`);
return readHelpFile(filename);
}
catch (error) {
const filename = path.resolve(__dirname, '../../help/commands-txt', `${DEFAULT_HELP}.txt`);
return readHelpFile(filename);
}
}
exports.default = help;
/***/ })
};
;
//# sourceMappingURL=862.index.js.map