UNPKG

st-open-api

Version:

Generates API client SDKs from an OpenAPI specification written in OpenAPI version 3.x.x

38 lines 1.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var chalk = require("chalk"); var fs_1 = require("fs"); var os_1 = require("os"); var is_directory_1 = require("./is-directory"); var st_rm_rf_linux_1 = require("./st-rm-rf-linux"); var st_rm_rf_windows_1 = require("./st-rm-rf-windows"); var DEFAULT_DELETE_PATH_PATH_OR_FILE_OPTION = { printInfo: true, printWarning: true, printError: true, }; exports.deletePathOrFile = function (deletePath, option) { if (option === void 0) { option = DEFAULT_DELETE_PATH_PATH_OR_FILE_OPTION; } try { var osDelete = os_1.platform() === "win32" ? st_rm_rf_windows_1.deletePathOrFile : st_rm_rf_linux_1.deletePathOrFile; var currentPath = process.cwd(); deletePath = osDelete.resolve(currentPath, deletePath); if (!fs_1.existsSync(deletePath)) { if (option.printWarning) { console.log(chalk.yellow("[!] Warning: Path does not exist: " + osDelete.relative(currentPath, deletePath))); } return; } var isFolder = is_directory_1.isDirectory(deletePath); if (option.printInfo) { console.log(chalk.cyan("[*] Deleting " + (isFolder ? "folder" : "file") + " " + chalk.white(osDelete.relative(currentPath, deletePath)) + "...")); } osDelete.deletePathOrFile(deletePath); } catch (err) { if (option.printError) { console.log(chalk.yellow("[!] Warning: ") + err); } } }; //# sourceMappingURL=st-rm-rf.js.map