-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathargv.js
37 lines (31 loc) · 792 Bytes
/
argv.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
"use strict";
const fs = require("fs");
const argv = require("minimist")(process.argv.slice(2));
const importType = argv._[0];
var path;
if (fs.existsSync(importType)) {
path = importType;
} else if (importType) {
console.log(importType);
path = importType;
} else if (!path || !fs.existsSync(importType)) {
throw "Please specify a valid file system path or a site you wish to copy";
}
const isRequested = (arg, value) => {
if (!value) {
return argv[arg];
}
if (typeof argv[arg] === "string") {
return argv[arg] === value;
}
if (Array.isArray(argv[arg])) {
return argv[arg].includes(value);
}
return false;
};
module.exports = {
path,
clean: entity => isRequested("clean", entity),
setup: argv.setup,
skip: step => isRequested("skip", step)
};