| Index: tools/vulcanize/node_modules/vulcanize/bin/vulcanize
|
| diff --git a/tools/vulcanize/node_modules/vulcanize/bin/vulcanize b/tools/vulcanize/node_modules/vulcanize/bin/vulcanize
|
| new file mode 100755
|
| index 0000000000000000000000000000000000000000..827079a626a904a50c6cae7101ef61d7573e56bf
|
| --- /dev/null
|
| +++ b/tools/vulcanize/node_modules/vulcanize/bin/vulcanize
|
| @@ -0,0 +1,92 @@
|
| +#!/usr/bin/env node
|
| +var path = require('path');
|
| +var fs = require('fs');
|
| +var nopt = require('nopt');
|
| +var vulcan = require('../lib/vulcan.js');
|
| +
|
| +var help = [
|
| + 'vulcanize: Concatenate a set of Web Components into one file',
|
| + '',
|
| + 'Options:',
|
| + ' --output, -o: Output file name (defaults to vulcanized.html)',
|
| + ' --verbose, -v: More verbose logging',
|
| + ' --help, -h, -?: Print this message',
|
| + ' --config: Read the given config file',
|
| + ' --strip, -s: Remove comments and empty text nodes',
|
| + ' --csp: Extract inline scripts to a separate file (uses <output file name>.js)',
|
| + ' --inline: The opposite of CSP mode, inline all assets (script and css) into the document',
|
| + '',
|
| + 'Config:',
|
| + ' JSON file for additional options',
|
| + '',
|
| + ' {',
|
| + ' "excludes": {',
|
| + ' "imports": [ "regex-to-exclude" ],',
|
| + // ' "styles": [ "regex-to-exclude" ],',
|
| + // ' "scripts": [ "regex-to-exclude" ],',
|
| + ' }',
|
| + ' }'
|
| +];
|
| +
|
| +function printHelp() {
|
| + console.log(help.join('\n'));
|
| + process.exit(0);
|
| +}
|
| +
|
| +var options = nopt(
|
| + {
|
| + 'config': path,
|
| + 'csp': Boolean,
|
| + 'help': Boolean,
|
| + 'inline': Boolean,
|
| + 'output': path,
|
| + 'strip': Boolean,
|
| + 'verbose': Boolean
|
| + },
|
| + {
|
| + '?': ['--help'],
|
| + 'h': ['--help'],
|
| + 'o': ['--output'],
|
| + 's': ['--strip'],
|
| + 'v': ['--verbose']
|
| + }
|
| +);
|
| +
|
| +if (options.help) {
|
| + printHelp();
|
| +}
|
| +
|
| +if (options.config) {
|
| + var configBlob;
|
| + var config;
|
| + try {
|
| + configBlob = fs.readFileSync(options.config, 'utf8');
|
| + } catch(e) {
|
| + console.log('Config file not found!');
|
| + process.exit(1);
|
| + }
|
| + try {
|
| + config = JSON.parse(configBlob);
|
| + } catch(e) {
|
| + console.error('Malformed config JSON!');
|
| + process.exit(1);
|
| + }
|
| + if (config.excludes) {
|
| + options.excludes = {
|
| + imports: config.excludes.imports
|
| + // styles: config.excludes.styles,
|
| + // scripts: config.excludes.scripts
|
| + };
|
| + }
|
| +}
|
| +
|
| +var argv = options.argv.remain;
|
| +if (argv[0]) {
|
| + options.input = path.resolve(argv[0]);
|
| +}
|
| +
|
| +if (vulcan.setOptions(options)) {
|
| + vulcan.processDocument();
|
| +} else {
|
| + process.exit(1);
|
| +}
|
|
|