UNPKG

@craftnotion/init-project

Version:

A CLI tool to initialize a new project with AdonisJS, NextJS, NestJS, React Native, Strapi, TypeScript, Husky, Git-CZ and more.

36 lines (35 loc) 1.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Base = void 0; const child_process_1 = require("child_process"); class Base { command; constructor(command) { this.command = command; } updateCommand(type, data) { // Add prefix based on type const prefix = type === 'alias' ? ' --' : ' -'; // If data is an array, append each item with prefix to the command if (Array.isArray(data)) { data.forEach((item) => { this.command += `${prefix}${item}`; }); return; } // If data is a string, simply append it to the command if (typeof data === 'string') { this.command += `${prefix}${data}`; return; } // If data is an object, iterate over its entries Object.entries(data).forEach(([key, value]) => { // If value is not undefined, append key=value, otherwise just append key this.command += `${prefix}${key}${value !== undefined ? `=${value}` : ''}`; }); } scaffold() { (0, child_process_1.execSync)(this.command, { stdio: 'inherit' }); } } exports.Base = Base;