UNPKG

xrefcli

Version:

CLI command for the searching through OpenEdge XREF

65 lines 2.11 kB
"use strict"; 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 fs = __importStar(require("fs")); const help_1 = require("../help"); class InitCommand { constructor(config) { this.config = config; } execute(params) { const promise = new Promise(resolve => { if (this.repo) { this.config.addRepo(this.repo); this.config.data.current = this.repo.name; console.log(this.repo.name); } resolve(); }); return promise; } validate(params) { const options = params['options']; if (options['help'] === true) { const help = new help_1.Help(); help.initCommand(); process.exit(0); } const name = options['name']; if (name === undefined || name === '') { console.error('Error: repo name should supplied'); return false; } const dir = options['dir']; if (dir === undefined || dir === '') { console.error('Error: xref directory (--dir) should be supplied'); return false; } if (!fs.existsSync(dir)) { console.error(`Error: directory '${dir}' does not exist`); return false; } const dirInfo = fs.lstatSync(dir); if (!dirInfo.isDirectory()) { console.error(`Error: '${dir}' is not a directory`); return false; } const srcdir = options['srcdir']; const srcroot = options['srcroot']; this.repo = { name: name.toLowerCase(), dir: dir, srcdir: srcdir, srcroot: srcroot }; return true; } } exports.InitCommand = InitCommand; //# sourceMappingURL=init.js.map