@procore/core-scripts
Version:
A CLI to enhance your development experience
64 lines • 2.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RmCommand = void 0;
const tslib_1 = require("tslib");
const command_1 = require("@oclif/command");
const del_1 = tslib_1.__importDefault(require("del"));
const enquirer_1 = require("enquirer");
const BaseCommand_1 = require("../BaseCommand");
class RmCommand extends BaseCommand_1.BaseCommand {
async run() {
// eslint-disable-next-line no-shadow
const { args, flags } = this.parse(RmCommand);
if (!flags.dryRun) {
// @ts-ignore https://github.com/oclif/oclif/issues/301
await this.promptConfirmation(flags, args);
}
const deletedFiles = await (0, del_1.default)(args.path, {
force: flags.force,
dryRun: flags.dryRun,
});
if (flags.dryRun) {
this.log(deletedFiles.join('\n'));
}
}
async promptConfirmation(flags, args) {
const response = await (0, enquirer_1.prompt)({
type: 'confirm',
initial: true,
name: 'shouldRun',
message: `Are you sure you want to remove "${args.path}"?`,
skip: flags.yes,
});
if (!response.shouldRun) {
this.exit(0);
}
}
}
exports.RmCommand = RmCommand;
RmCommand.description = 'Removes things.';
RmCommand.args = [
{
name: 'path',
required: true,
description: 'Path that will be remove.',
},
];
RmCommand.flags = {
yes: command_1.flags.boolean({
default: false,
char: 'y',
description: "Automatically answer 'Yes' to the question.",
}),
dryRun: command_1.flags.boolean({
default: false,
char: 'd',
description: 'List what would be deleted instead of deleting.',
}),
force: command_1.flags.boolean({
default: false,
char: 'f',
description: 'Allow deleting the current working directory and outside.',
}),
};
//# sourceMappingURL=rm.js.map