-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodules.mjs
43 lines (38 loc) · 996 Bytes
/
modules.mjs
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
import { readdirSync } from 'fs'
/**
* Get an array of all subdirectories
* @param source {String} path of root directory
* @returns {Array} List of subdirectories
*/
export const getFiles = source =>
readdirSync(source, { withFileTypes: true })
.map(dirent =>
dirent.name
);
/**
* Verify there is a node argument and return world path
* @param argv contents of process.argv()
* @returns {String} path to world
*/
export function validateArgs(argv) {
// get worldPath
const worldPath = argv[2];
// exit and alert user if there are no arguments
if (worldPath === undefined) {
console.log("invalid arguments")
process.exit();
}
return worldPath;
};
/**
* Convert names to kebab case
* @param {string} Name to convert
* @returns {string} Name in kebab case
*/
/* export const toKebabCase = name =>
name &&
name
.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
.map(x => x.toLowerCase())
.join('-');
*/