UNPKG

@ts-dev-tools/core

Version:
36 lines (35 loc) 1.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.deleteFolderRecursive = deleteFolderRecursive; exports.copyFolderSync = copyFolderSync; var fs_1 = require("fs"); var path_1 = require("path"); function deleteFolderRecursive(path) { if ((0, fs_1.existsSync)(path)) { (0, fs_1.readdirSync)(path).forEach(function (file) { var curPath = (0, path_1.join)(path, file); if ((0, fs_1.lstatSync)(curPath).isDirectory()) { // recurse deleteFolderRecursive(curPath); } else { // delete file (0, fs_1.unlinkSync)(curPath); } }); (0, fs_1.rmdirSync)(path); } } function copyFolderSync(from, to) { if (!(0, fs_1.existsSync)(to)) { (0, fs_1.mkdirSync)(to); } (0, fs_1.readdirSync)(from).forEach(function (element) { if ((0, fs_1.lstatSync)((0, path_1.join)(from, element)).isFile()) { (0, fs_1.copyFileSync)((0, path_1.join)(from, element), (0, path_1.join)(to, element)); } else { copyFolderSync((0, path_1.join)(from, element), (0, path_1.join)(to, element)); } }); }