@softkit/i18n
Version:
This library is a simple wrapper based on [nestjs-i18n](https://nestjs-i18n.com/)
57 lines • 2.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.VersionCommand = void 0;
const node_child_process_1 = require("node:child_process");
/**
* Shows nestjs-i18n version.
*/
class VersionCommand {
constructor() {
this.command = 'version';
this.describe = 'Prints NestJS I18n version this project uses.';
}
static executeCommand(command) {
return new Promise((ok, fail) => {
(0, node_child_process_1.exec)(command, (error, stdout, stderr) => {
if (stdout)
return ok(stdout);
if (stderr)
return ok(stderr);
if (error)
return fail(error);
ok('');
});
});
}
async handler() {
const localNpmList = await VersionCommand.executeCommand('npm list --depth=0');
const localMatches = localNpmList.match(/ nestjs-i18n@(.*)\n/);
const localNpmVersion = (localMatches && localMatches[1] ? localMatches[1] : '')
.replaceAll(/"invalid"/gi, '')
.trim();
const globalNpmList = await VersionCommand.executeCommand('npm list -g --depth=0');
const globalMatches = globalNpmList.match(/ nestjs-i18n@(.*)\n/);
const globalNpmVersion = (globalMatches && globalMatches[1] ? globalMatches[1] : '')
.replaceAll(/"invalid"/gi, '')
.trim();
if (localNpmVersion) {
console.log('Local installed version:', localNpmVersion);
}
else {
console.log('No local installed was found.');
}
if (globalNpmVersion) {
console.log('Global installed i18n module version:', globalNpmVersion);
}
else {
console.log('No global installed was found.');
}
if (localNpmVersion &&
globalNpmVersion &&
localNpmVersion !== globalNpmVersion) {
console.log('To avoid issues with CLI please make sure your global and local versions match, ');
}
}
}
exports.VersionCommand = VersionCommand;
//# sourceMappingURL=version.command.js.map