UNPKG

@lcap/builder

Version:
45 lines (44 loc) 2.43 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.copyFiles = copyFiles; const fs_extra_1 = __importDefault(require("fs-extra")); const path_1 = __importDefault(require("path")); function copyFolder(sourceFolder, destinationFolder) { if (!fs_extra_1.default.existsSync(sourceFolder)) { return; } if (!fs_extra_1.default.existsSync(destinationFolder)) { fs_extra_1.default.mkdirSync(destinationFolder, { recursive: true }); } fs_extra_1.default.readdirSync(sourceFolder).forEach((file) => { const sourceFilePath = path_1.default.resolve(sourceFolder, file); const destinationFilePath = path_1.default.resolve(destinationFolder, file); if (fs_extra_1.default.lstatSync(sourceFilePath).isDirectory()) { copyFolder(sourceFilePath, destinationFilePath); } else { fs_extra_1.default.copyFileSync(sourceFilePath, destinationFilePath); } }); } function copyFiles(context) { return __awaiter(this, void 0, void 0, function* () { // 复制api.ts fs_extra_1.default.copyFileSync(path_1.default.resolve(context.pkgComponentFolderPath, 'api.ts'), path_1.default.resolve(context.componentFolderPath, 'api.ts')); // 复制 截图 copyFolder(path_1.default.resolve(context.pkgComponentFolderPath, 'screenshots'), path_1.default.resolve(context.componentFolderPath, 'screenshots')); copyFolder(path_1.default.resolve(context.pkgComponentFolderPath, 'drawings'), path_1.default.resolve(context.componentFolderPath, 'drawings')); }); }