UNPKG

4.08 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3// Dependencies
4var program = require("commander");
5var path_1 = require("path");
6var os_1 = require("os");
7// Local exports
8var meta = require('../package.json');
9var charsets_1 = require("./charsets");
10var commands_1 = require("./commands");
11// Action
12program
13 .version(meta.version)
14 .description('CLI version of node-makensis')
15 .arguments('[command] [file.nsi]')
16 .usage('[command] [file.nsi] [options]')
17 .option('-i, --input-charset <string>', 'ACP|OEM|CP#|UTF8|UTF16<LE|BE>')
18 .option('-j, --json', 'prints output as JSON')
19 .option('-W, --pause', 'pauses after execution')
20 .option('-o, --output-charset <string>', 'ACP|OEM|CP#|UTF8[SIG]|UTF16<LE|BE>[BOM]')
21 .option('-P, --ppo', 'preprocess to stdout/file')
22 .option('-S, --safe-ppo', 'safely preprocess to stdout/file')
23 .option('-p, --priority <n>', 'process priority, where n is 5=realtime,4=high,3=above normal,2=normal,1=below normal,0=idle', parseInt)
24 .option('-v, --verbose <n>', 'verbosity where n is 4=all,3=no script,2=no info,1=no warnings,0=none', parseInt)
25 .option('-w, --wine', 'use Wine to run makenis')
26 .option('-x, --strict', 'treat warnings as errors')
27 .action(function (cmd, filePath, flags) {
28 var inputCharset = (typeof flags.inputCharset !== 'undefined' && charsets_1.input.includes(flags.inputCharset.toUpperCase())) ? flags.inputCharset.toUpperCase() : '';
29 var noCD = (typeof flags.nocd === 'undefined') ? false : true;
30 var noConfig = (typeof flags.noconfig === 'undefined') ? false : true;
31 var outputCharset = (typeof flags.outputCharset !== 'undefined' && charsets_1.output.includes(flags.outputCharset.toUpperCase())) ? flags.outputCharset.toUpperCase() : '';
32 var pause = (typeof flags.pause === 'undefined') ? false : true;
33 var ppo = (typeof flags.ppo === 'undefined') ? false : true;
34 var priority = (flags.priority >= 0 && flags.priority <= 5) ? flags.priority : null;
35 var json = (typeof flags.json === 'undefined') ? false : true;
36 var safePPO = (typeof flags.safePpo === 'undefined') ? false : true;
37 var strict = (typeof flags.strict === 'undefined') ? false : true;
38 var verbose = (flags.verbose >= 0 && flags.verbose <= 4) ? flags.verbose : null;
39 var wine = (typeof flags.wine === 'undefined') ? false : true;
40 if (os_1.platform() === 'win32' || wine === true) {
41 outputCharset = (typeof flags.outputCharset !== 'undefined') ? flags.outputCharset : '';
42 outputCharset = (typeof flags.priority !== 'undefined') ? flags.priority : '';
43 }
44 var options = {
45 'inputCharset': inputCharset,
46 'json': json,
47 'noCD': noCD,
48 'noConfig': noConfig,
49 'outputCharset': outputCharset,
50 'pause': pause,
51 'ppo': ppo,
52 'safePPO': safePPO,
53 'priority': priority,
54 'strict': strict,
55 'verbose': verbose,
56 'wine': wine
57 };
58 switch (cmd) {
59 case 'flags':
60 case 'hdrinfo':
61 case 'info':
62 commands_1.hdrinfo(options);
63 break;
64 case 'version':
65 commands_1.version(options);
66 break;
67 case 'cmdhelp':
68 case 'help':
69 filePath = (typeof filePath === 'undefined') ? '' : filePath;
70 commands_1.cmdhelp(filePath, options);
71 break;
72 case 'help':
73 program.help();
74 break;
75 case 'dir':
76 case 'nsisdir':
77 commands_1.nsisdir(options);
78 break;
79 case 'license':
80 commands_1.license(options);
81 break;
82 case 'new':
83 case 'scaffold':
84 commands_1.scaffold();
85 break;
86 default:
87 if (typeof cmd !== 'undefined' && (path_1.extname(cmd) === '.nsi' || path_1.extname(cmd) === '.bnsi')) {
88 commands_1.compile(cmd, options);
89 break;
90 }
91 program.help();
92 }
93})
94 .parse(process.argv);
95if (program.args.length === 0)
96 program.help();