Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: tools/vulcanize/node_modules/vulcanize/bin/vulcanize

Issue 125733002: Add vulcanize to tools. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
+}
« no previous file with comments | « tools/vulcanize/node_modules/vulcanize/README.md ('k') | tools/vulcanize/node_modules/vulcanize/lib/vulcan.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698