-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.js
50 lines (42 loc) · 1016 Bytes
/
helpers.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { promises as fs } from "fs";
import chalk from "chalk";
const doesFileExist = async (filePath) => {
try {
await fs.access(filePath);
return true; // Exists
} catch (error) {
return false; // Doesn't exist
}
};
const iFileNameValid = (string) => {
return /^[A-Za-z][A-Za-z0-9-]*$/.test(string);
};
const consoleDone = () => {
console.log(chalk`
{rgb(0, 255, 251) Done!}`);
};
const consoleDryRunMessage = () => {
console.log(
chalk`
{rgb(255, 225, 0) Command executed with dry-run enabled; no files have been created}`
);
};
const consoleCreate = (filename) => {
console.log(chalk`{rgb(0, 255, 179) Create:} ${filename}`);
};
const consoleUpdate = (filename) => {
console.log(chalk`{rgb(0, 166, 255) Update:} ${filename}`);
};
const consoleError = (message) => {
console.log(chalk.redBright("ERROR"));
console.log(message);
};
export {
doesFileExist,
consoleDone,
consoleCreate,
iFileNameValid,
consoleError,
consoleDryRunMessage,
consoleUpdate,
};