UNPKG

tsdk

Version:

Type-safe API development and code share tool for TypeScript projects.

44 lines (43 loc) 2.32 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()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.runNestCommand = void 0; const child_process_1 = require("child_process"); const fs_extra_1 = __importDefault(require("fs-extra")); const path_1 = __importDefault(require("path")); const symbols_1 = __importDefault(require("./symbols")); function runNestCommand() { return __awaiter(this, void 0, void 0, function* () { const idx = process.argv.findIndex((i) => i === '--nest'); const command = process.argv[idx + 1]; if (command === 'build') { const cwd = process.cwd(); const webpackDistFile = path_1.default.resolve(cwd, 'node_modules', 'nest-webpack.js'); const copyFiles = ['nest-webpack.js', 'get-pkg-manager.js']; yield Promise.all(copyFiles.map((filename) => { return fs_extra_1.default.copy(path_1.default.resolve(__dirname, `../lib/${filename}`), path_1.default.resolve(cwd, 'node_modules', filename), { overwrite: true, }); })); const names = process.argv.filter((i, index) => index > idx + 1); (0, child_process_1.execSync)(`node ${webpackDistFile} ${command} --names ${names.join(' ')}`, { stdio: 'inherit', }); } else { console.log(symbols_1.default.warning, `\`tsdk --nest\` currently only support \`build\` command.`); } }); } exports.runNestCommand = runNestCommand;