1 | import {GitSimulator} from "./classLibrary/GitSimulator";
|
2 | import chalk from "chalk";
|
3 | import * as path from "path";
|
4 | import {GenerateTemplate, Interrogate} from "./generator";
|
5 | import * as rimraf from "rimraf";
|
6 | import {Dependency} from "./Depedency";
|
7 |
|
8 |
|
9 | export async function Try(dep: Dependency, from: string, to: string, git: boolean, copyNode: boolean): Promise<string> {
|
10 | let f: string = path.resolve(process.cwd(), from);
|
11 | if (git) {
|
12 | let gitSimulate: GitSimulator = new GitSimulator(dep.core);
|
13 | f = await gitSimulate.SimulateGit(process.cwd(), from);
|
14 | console.log(chalk.blueBright(f));
|
15 | }
|
16 | let ret = "";
|
17 | try {
|
18 | let cyanSafe = await Interrogate(dep, dep.autoInquirer, f, to);
|
19 |
|
20 | let logger = console.log;
|
21 | console.log = function (...args) {
|
22 | logger.apply(console, args);
|
23 | };
|
24 |
|
25 | ret = await GenerateTemplate(dep, f, to, cyanSafe, copyNode);
|
26 |
|
27 | } catch (e) {
|
28 | ret = chalk.redBright(e);
|
29 | }
|
30 | if (git) {
|
31 | rimraf.sync(f);
|
32 | }
|
33 | return ret;
|
34 | }
|