UNPKG

xrefcli

Version:

CLI command for the searching through OpenEdge XREF

73 lines 3.2 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result["default"] = mod; return result; }; Object.defineProperty(exports, "__esModule", { value: true }); const http = __importStar(require("http")); const help_1 = require("../help"); class AboutCommand { constructor(config) { this.config = config; } execute(params) { return __awaiter(this, void 0, void 0, function* () { console.log('\nXREFCLI, OpenEdge XREF information from the command line'); console.log('---------------------------------------------------------------'); const pkginfo = require('pkginfo')(module, 'version', 'author'); if (module.exports['author']['name'] === undefined) { console.log('author: ', module.exports['author']); } else { console.log('author: ', module.exports['author']['name'] + ' <' + module.exports['author']['email'] + '>'); } const version = module.exports['version']; console.log('version:', version); // fetch information on latest const promise = new Promise((resolve, reject) => { const req = http.get('http://registry.npmjs.com/xrefcli', res => { let body = ''; res.on('data', (data) => { body += data; }); res.on('end', () => { const npmRegistry = JSON.parse(body); const latest = npmRegistry['dist-tags']['latest']; console.log('latest: ', latest); if (latest !== version) { console.log('Newer version available, use "npm i xrefcli -g" to update'); } resolve(); }); }); // hide errors req.on('error', (err) => { resolve(); }); }); return promise; }); } validate(params) { const options = params['options']; if (options['help'] === true) { const help = new help_1.Help(); help.aboutCommand(); process.exit(0); } return true; } } exports.AboutCommand = AboutCommand; //# sourceMappingURL=about.js.map