-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.ts
42 lines (35 loc) · 1.08 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import path from "path";
import fs from "fs";
import inquirer from "inquirer";
import { greeting, success } from "./helpers/log";
import { copyRecursiveSync } from "./helpers/copyRecursiveSync";
async function run() {
greeting();
let themeFolderName: string | undefined;
const questions: any = [
{
type: "input",
name: "folderName",
message: "What's the project folder name?",
default: () => "ikas-theme",
validate(folderName: string) {
if (fs.existsSync(folderName)) {
return `Folder already exists: ${folderName}.\nPlease enter different name which does not exist.`;
}
return true;
},
},
];
const answers = await inquirer.prompt(questions);
themeFolderName = answers.folderName;
if (!themeFolderName) return;
fs.mkdirSync(themeFolderName);
// process.chdir(`${process.cwd()}/${themeFolderName}`);
const destination = path.resolve(themeFolderName);
copyRecursiveSync(
path.join(__dirname, "templates", "typescript"),
destination
);
success({ folderName: themeFolderName });
}
run();