|
|
|
@ -30,8 +30,8 @@ function printHelp() {
|
|
|
|
|
console.log(" to peg.generate");
|
|
|
|
|
console.log(" --extra-options-file <file> file with additional options (in JSON");
|
|
|
|
|
console.log(" format) to pass to peg.generate");
|
|
|
|
|
console.log(" --format <format> format of the generated parser: amd,");
|
|
|
|
|
console.log(" commonjs, globals, umd (default: commonjs)");
|
|
|
|
|
console.log(" --format <format> format of the generated parser: amd, commonjs");
|
|
|
|
|
console.log(" es, globals, umd (default: commonjs)");
|
|
|
|
|
console.log(" -h, --help print help and exit");
|
|
|
|
|
console.log(" -O, --optimize <goal> select optimization for speed or size");
|
|
|
|
|
console.log(" (default: speed)");
|
|
|
|
@ -116,6 +116,9 @@ let options = {
|
|
|
|
|
trace: false
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const MODULE_FORMATS = ["amd", "commonjs", "es", "globals", "umd"];
|
|
|
|
|
const MODULE_FORMATS_WITH_DEPS = ["amd", "commonjs", "es", "umd"];
|
|
|
|
|
|
|
|
|
|
while (args.length > 0 && isOption(args[0])) {
|
|
|
|
|
let json, id, mod;
|
|
|
|
|
|
|
|
|
@ -183,8 +186,8 @@ while (args.length > 0 && isOption(args[0])) {
|
|
|
|
|
if (args.length === 0) {
|
|
|
|
|
abort("Missing parameter of the --format option.");
|
|
|
|
|
}
|
|
|
|
|
if (args[0] !== "amd" && args[0] !== "commonjs" && args[0] !== "globals" && args[0] !== "umd") {
|
|
|
|
|
abort("Module format must be one of \"amd\", \"commonjs\", \"globals\", and \"umd\".");
|
|
|
|
|
if (MODULE_FORMATS.indexOf(args[0]) === -1) {
|
|
|
|
|
abort("Module format must be one of " + MODULE_FORMATS.map(format => `"${format}"`).join(", ") + ".");
|
|
|
|
|
}
|
|
|
|
|
options.format = args[0];
|
|
|
|
|
break;
|
|
|
|
@ -253,7 +256,7 @@ while (args.length > 0 && isOption(args[0])) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Object.keys(options.dependencies).length > 0) {
|
|
|
|
|
if (options.format !== "amd" && options.format !== "commonjs" && options.format !== "umd") {
|
|
|
|
|
if (MODULE_FORMATS_WITH_DEPS.indexOf(options.format) === -1) {
|
|
|
|
|
abort("Can't use the -d/--dependency option with the \"" + options.format + "\" module format.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|