1 | import {Dependency} from "./Depedency";
|
2 | import {Group} from "./classLibrary/Group";
|
3 | import path from "path";
|
4 | import chalk from "chalk";
|
5 | import {Template} from "./classLibrary/Template";
|
6 | import rimraf = require("rimraf");
|
7 |
|
8 | async function RemoveTemplate(dep: Dependency, key: string, group: string): Promise<string> {
|
9 | const g: Group = new Group(dep.core, dep.objex, path.resolve(__dirname, '../templates'), dep.util);
|
10 | if (!g.Exist(group)) return chalk.red(`Group ${chalk.cyanBright(key)} does not exist!`);
|
11 | const template: Template = new Template(group, key, "", "", g);
|
12 | if (!template.Exist()) return chalk.red(`Template ${chalk.cyanBright(key)} does not exist within Group ${chalk.cyanBright(group)}`);
|
13 | const sure = await dep.autoInquirer.InquirePredicate(`Are you sure you want to remove ${key} from Group ${group}? This cannot be undone.`);
|
14 | if (!sure) return "User cancelled";
|
15 | rimraf.sync(template.Target);
|
16 | template.DeleteGroupEntry();
|
17 | return chalk.greenBright("Template successfully deleted");
|
18 | }
|
19 |
|
20 | export {RemoveTemplate}
|