1import { Task } from './Task';
2import chalk from 'chalk';
3import fs from 'fs-extra';
4
5export type RemoveDirectorySettings = {
6  target?: string;
7  name?: string;
8};
9
10/**
11 * A task which will remove the working directory.
12 */
13export class RemoveDirectory extends Task {
14  private target?: string;
15
16  constructor({ target }: RemoveDirectorySettings) {
17    super();
18    this.target = target;
19  }
20
21  protected overrideWorkingDirectory(): string | undefined {
22    return this.target;
23  }
24
25  async execute() {
26    const workDirectory = this.getWorkingDirectory();
27
28    this.logSubStep(
29      `�� remove ${chalk.yellow(this.overrideWorkingDirectory() || '<workingDirectory>')}`
30    );
31    return await fs.remove(workDirectory);
32  }
33}
34