-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·48 lines (38 loc) · 1.1 KB
/
cli.js
File metadata and controls
executable file
·48 lines (38 loc) · 1.1 KB
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
#!/usr/bin/env node
const path = require('path');
const fs = require('fs');
const { downloadThemeLiquidDocs, root } = require(path.resolve(__dirname, '../dist'));
// Get the command line arguments
const args = process.argv.slice(2);
// Check if a command was provided
if (args.length === 0) {
console.log(`
Please provide a command.
Usage:
download <dir> \t\tDownloads all docsets and JSON Schemas to the specified directory.
root \tPrints the default docsets root directory.
clear-cache \tClears the default docsets root directory.
`);
process.exit(1);
}
// Handle the command
switch (args[0]) {
case 'download':
if (args.length > 2) {
console.log('Please provide a directory to download docs into.');
process.exit(1);
}
console.log('Downloading docs...');
downloadThemeLiquidDocs(args[1], console.error.bind(console));
break;
case 'root':
console.log(root);
break;
case 'clear-cache':
console.log(`Removing '${root}'`);
fs.rmSync(root, { recursive: true });
break;
default:
console.log(`Unknown command: ${args[0]}`);
process.exit(1);
}