UNPKG

1.41 kBJavaScriptView Raw
1#!/usr/bin/env node
2
3const fs = require('fs');
4const path = require('path');
5const blaze = require("./lib/blaze.js");
6const { spawn } = require('child_process');
7const program = require('commander');
8const package = require('./package.json');
9
10program
11 .version(package.version, '-v, --version, version');
12
13program
14 .command('start <dir>')
15 .description('Start a Blaze Web Server instance')
16 .action(
17 async (dir, options) => {
18 await blaze.start(dir);
19 console.log('Starting Blaze');
20 }
21 );
22
23program
24 .command('install <dir>')
25 .alias('i')
26 .description('Install the Blaze Web Server')
27 .action(
28 async (dir, options) => {
29 await blaze.install(dir);
30 }
31 );
32
33program
34 .command('uninstall <dir>')
35 .alias('u')
36 .description('Uninstall the Blaze Web Server')
37 .action(
38 async (dir, options) => {
39 await blaze.uninstall(dir);
40 }
41 );
42
43program
44 .command('parse <dir>')
45 .alias('i')
46 .option('-n, --name [name]', 'instance name')
47 .description('Parse Blaze templates')
48 .action(
49 async (dir, options) => {
50 let context = {}
51 if (options.hasOwnProperty('context')) {
52 try {
53 context = JSON.parse(options.context);
54 } catch { }
55 }
56 await blaze.parse(dir, options.hasOwnProperty('parser') ? options.parser : null, context);
57 }
58 );
59
60try {
61 program.parse(process.argv);
62} catch (error) {
63 console.error('ERROR: ' + error);
64}
\No newline at end of file