generated from valkyrie-language/legion-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
37 lines (31 loc) · 1.06 KB
/
index.js
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
import fs from "fs-extra";
import prompts from "prompts";
import {validateName} from "./src/validateName.js";
import chalk from "chalk";
import {copyFile, cp, readFile, writeFile} from "node:fs/promises";
import {basename, dirname, resolve} from "node:path";
import {fileURLToPath} from "node:url";
import * as constants from "node:constants";
import {execSync} from "child_process";
import {jsInstall} from "./src/jsInstall.js";
import {checkOverride} from "./src/checkOverride.js";
import {copyTemplate} from "./src/copyTemplate.js";
/**
* @param {string} target Target directory
* @param {string} name Package name
* @returns {Promise<void>}
*/
export async function makeTemplate (target, name) {
validateName(name);
await checkOverride(target);
const here = dirname(fileURLToPath(import.meta.url))
await copyTemplate(target, here, name);
await jsInstall(target);
console.log();
console.log(
`${chalk.green("✔")} Success! Created ${chalk.cyan(
name
)} at ${chalk.cyan(target)}`
);
console.log();
}