UNPKG

piral-cli

Version:

The standard CLI for creating and building a Piral instance or a Pilet.

38 lines 1.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.select = select; const path_1 = require("path"); const fs_1 = require("fs"); const child_process_1 = require("child_process"); function getPath() { try { return (0, path_1.dirname)(require.resolve('piral-cli/lib', { paths: [process.cwd()], })); } catch { return (0, path_1.dirname)(__filename); } } async function select(from) { const localPath = getPath(); const localRunner = (0, path_1.resolve)(localPath, 'runner.js'); if (localPath !== __dirname && (0, fs_1.existsSync)(localRunner)) { // If the runner exists and we found a more local installation use the new mode const ps = (0, child_process_1.fork)(localRunner, [], { cwd: process.cwd(), }); ps.send({ type: 'start', select: from.toString(), args: process.argv.slice(2), }); ps.on('exit', (code) => process.exit(code)); } else { // If no runner exists or we are in the same directory go for the classic mode const { start } = require((0, path_1.join)(localPath, 'start')); await start(from); } } //# sourceMappingURL=select.js.map