UNPKG

@sap/cli-core

Version:

Command-Line Interface (CLI) Core Module

29 lines (28 loc) 1.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const cache_1 = require("../../../cache"); const constants_1 = require("../../../constants"); const options_1 = require("../../../utils/options"); const handler_1 = require("../../handler"); const OPTION_PURGE_ALL = { longName: "purge-all", description: "clean the whole local CLI cache", }; const cleanHandler = async () => async () => { const purgeAll = (0, options_1.getOptionValueFromConfigGracefully)(OPTION_PURGE_ALL); if (purgeAll) { await (0, cache_1.cleanCache)(); } else { const files = (await (0, cache_1.getFiles)()).filter((file) => file.startsWith(constants_1.DISCOVERY_DOCUMENT_PREFIX)); await Promise.all(files.map(async (file) => (0, cache_1.deleteFile)(file))); } }; const cleanCommand = { type: "command", command: "clean", description: "clean the local CLI cache", handler: (0, handler_1.createNextHandler)("command.config.cache.clean", (0, handler_1.createParseArgumentsHandler)(), cleanHandler), options: [OPTION_PURGE_ALL], }; exports.default = cleanCommand;