UNPKG

mili

Version:

Scaffolding with continuous control over the development of the project.

47 lines (46 loc) 2.06 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 }); exports.copy = void 0; const fs = require("fs-extra"); const simple_git_1 = require("simple-git"); const ora = require("ora"); const path = require("path"); const exec_1 = require("./exec"); function copy(src, dist, showProgress = false) { return __awaiter(this, void 0, void 0, function* () { const git = (0, simple_git_1.default)(src); const spinner = ora({ text: 'Load Files', discardStdin: true, }); if (showProgress) spinner.start(); const files = yield fs.readdir(src); const filepaths = []; for (const filepath of files) { const srcfilepath = path.join(src, filepath); const result = yield git.checkIgnore(srcfilepath); if (result.length) continue; const stat = yield fs.lstat(srcfilepath); if (stat.isDirectory()) filepaths.push(`${filepath}/.`); else filepaths.push(filepath); } const tarOutput = path.relative(src, dist); yield (0, exec_1.exec)(`tar -cf ${tarOutput}.tar ${filepaths.join(' ')} && tar -xf ${dist}.tar -C ${dist}`, { cwd: src }); if (showProgress) spinner.succeed('Load All Files'); }); } exports.copy = copy;