-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.js
52 lines (41 loc) · 1.23 KB
/
functions.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
51
52
const path = require('path')
const fs = require('fs')
const makeDir = require('make-dir');
const { exec } = require("child_process");
const prompt = require('prompt-sync')();
function questionAsync(prompt_) {
return prompt(prompt_);
}
let copyRecursiveSync = function (src, dest) {
let exists = fs.existsSync(src);
let stats = exists && fs.statSync(src);
let isDirectory = exists && stats.isDirectory();
if (isDirectory) {
fs.mkdirSync(dest);
fs.readdirSync(src).forEach(function (childItemName) {
copyRecursiveSync(path.join(src, childItemName),
path.join(dest, childItemName));
});
} else {
fs.copyFileSync(src, dest);
}
};
const l = async function (message, type) {
console.log(message);
return
switch (type) {
case 'e':
console.log(chalk.white.bgRed(message));
break;
case 'd':
console.log(chalk.black.bgYellow(message));
break;
case 'l':
console.log(chalk.white.bgBlack(message));
break;
default:
console.log(chalk.white.bgBlack(message));
break;
}
}
module.exports = { copyRecursiveSync, questionAsync, l }