-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpaperboy-cli.js
executable file
·43 lines (36 loc) · 1.07 KB
/
paperboy-cli.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
#!/usr/bin/env node
import chalk from "chalk";
import { readFileSync } from "fs";
import { Paperboy } from "@neoskop/paperboy";
import { program } from "commander";
program.version("2.9.1").description("Paperboy CLI");
program
.description(
"Continuously watches a queue and rebuilds the frontend when a message is received"
)
.option("-c --config [config]", "Path to config file")
.action((program) => {
const paperboy = setupPaperboy(program);
paperboy.start();
});
program.parse(process.argv);
function setupPaperboy(program, configModifier) {
let config;
let configPath = program.config || "paperboy.config.json";
console.log(chalk.bold.cyan("[Paperboy] Starting …"));
try {
config = JSON.parse(readFileSync(configPath));
} catch (e) {
console.error(`Config file ${configPath} not found!`);
process.exit(1);
}
if (configModifier) {
configModifier(config);
}
return new Paperboy({
readinessHook: config.readinessHook,
initialCommand: config.initialCommand,
command: config.command,
queue: config.queue,
});
}