-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.js
84 lines (71 loc) · 2.22 KB
/
common.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env node
const readlinePromises = require('node:readline/promises');
let command = process.argv[2]
const helpMessage = [
'Options:\n',
' -b | --boilerplate Generate HTML boilerplate\n',
' -c | --convert Convert px to rem\n',
' -h | --help Show help\n',
' -l | --lorem Get lorem ipsum text\n',
' -r | --readme Generate README.md\n',
'\n',
'Usage:\n',
' common --boilerplate\n',
' common --convert 64\n',
' common --lorem 2\n',
' common --readme "project name"\n',
' common --help\n',
].join("")
if (command != null) {
command = command.toLowerCase();
if (command == "--help" || command == '-h') {
console.log('Common Helpers\n');
console.log(helpMessage);
}
else if (command == "--readme" || command == '-r') {
(async () => {
let repoName = "";
const rl = readlinePromises.createInterface({
input: process.stdin,
output: process.stdout,
});
if (process.argv[3] !== undefined) {
repoName = process.argv[3];
}
else {
repoName = await rl.question('What is the projects name? ');
rl.close();
}
const readme = require('./tools/generate-readme.js');
readme.generate(repoName);
})()
}
else if (command == "--boilerplate" || command == '-b') {
const boilerplate = require('./tools/boilerplate/boilerplate.js');
boilerplate.generate();
}
else if (command == "--convert" || command == '-c') {
let num = "";
if (process.argv[3] !== undefined) {
num = process.argv[3];
}
const rem = require('./tools/rem.js');
rem.convert(num);
}
else if (command == "--lorem" || command == '-l') {
let num = "";
if (process.argv[3] !== undefined) {
num = process.argv[3];
}
const getLorem = require('./tools/lorem.js');
getLorem.lorem(num);
}
else {
console.log("\nPlease use a valid command\n");
console.log(helpMessage);
}
return
}
else {
console.log(helpMessage)
}