UNPKG

@modyo/cli

Version:

Modyo CLI Command line to expose local development tools

28 lines (27 loc) 1.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const adm_zip_1 = tslib_1.__importDefault(require("adm-zip")); const fs_extra_1 = require("fs-extra"); const core_1 = require("@oclif/core"); const debug_1 = tslib_1.__importDefault(require("debug")); const debug = (0, debug_1.default)('get/extracting-template-files.ts'); async function extractingTemplateFiles({ zipPath, finalPath, override, }) { const existFinalPath = (0, fs_extra_1.existsSync)(finalPath); if (existFinalPath) { if (override) { core_1.ux.action.start(`Removing folder ${finalPath} to override`); await (0, fs_extra_1.remove)(finalPath); core_1.ux.action.stop(); } else { debug('failed because can\'t override'); throw new Error("Can't Override Folder"); } } const zip = new adm_zip_1.default(zipPath); core_1.ux.action.start(`Extracting to ${finalPath}`); zip.extractAllTo(finalPath, override); core_1.ux.action.stop(); } exports.default = extractingTemplateFiles;