UNPKG

@lenne.tech/cli

Version:

lenne.Tech CLI: lt

48 lines (47 loc) 1.99 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 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) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const path_1 = require("path"); /** * Rename current CLI */ const NewCommand = { alias: ['r'], description: 'Rename current CLI', hidden: false, name: 'rename', run: (toolbox) => __awaiter(void 0, void 0, void 0, function* () { // Retrieve the tools we need const { npm, parameters, print: { error, info }, system, } = toolbox; // Info info('Rename current CLI'); // Get root path const { path: packagePath } = yield npm.getPackageJson(); if (!packagePath) { error('The path to the root directory could not be found.'); return; } const rootPath = (0, path_1.dirname)(packagePath); if (!rootPath) { error('The path to the root directory could not be found.'); return; } // Run rename script yield system.run(`cd ${rootPath} && ${toolbox.pm.run('rename', toolbox.pm.detect(rootPath))} -- ${parameters.string}`); // Exit if not running from menu if (!toolbox.parameters.options.fromGluegunMenu) { process.exit(); } // For tests return `renamed cli in ${rootPath}`; }), }; exports.default = NewCommand;