Repository: Polymer/vulcanize
Pull request #265 (2015-10-20 14:37:41)

add new output option


Patch:
diff --git a/.travis.yml b/.travis.yml
index be3568a..c3e3870 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,5 @@
 language: node_js
 node_js:
   - "0.10"
-  - "0.12"
   - "4"
 sudo: false
diff --git a/README.md b/README.md
index fa13827..54396f1 100644
--- a/README.md
+++ b/README.md
@@ -33,6 +33,7 @@ for this step).
 - `--redirect <uri>|<path>`: Takes an argument in the form of URI|PATH where url is a URI composed of a protocol, hostname, and path and PATH is a local filesystem path to replace the matched URI part with. Multiple redirects may be specified; the earliest ones have the highest priority.
 - `--strip-comments`: Strips all HTML comments not containing an @license from the document.
 - `--no-implicit-strip`: *DANGEROUS*! Avoid stripping imports of the transitive dependencies of imports specified with `--exclude`. May result in duplicate javascript inlining.
+- `--out-html <path>`: If specified, output will be written to <path> instead of stdout.
 
 ## Usage
 The command
diff --git a/bin/vulcanize b/bin/vulcanize
index b7b2b56..042a9c2 100755
--- a/bin/vulcanize
+++ b/bin/vulcanize
@@ -13,6 +13,7 @@
 'use strict';
 
 var nopt = require('nopt');
+var fs = require('fs');
 var vulcan = require('../lib/vulcan');
 
 var help = [
@@ -33,6 +34,7 @@ var help = [
   '  --strip-comments: Strips all HTML comments not containing an @license from the document',
   '  --redirect <uri>|<path>: Takes an argument in the form of URI|PATH where url is a URI composed of a protocol, hostname, and path and PATH is a local filesystem path to replace the matched URI part with. Multiple redirects may be specified; the earliest ones have the highest priority.',
   '  --no-implicit-strip: DANGEROUS! Avoid stripping imports of the transitive dependencies of imports specified with `--exclude`. May result in duplicate javascript inlining.',
+  '  --out-html <path>: If specified, output will be written to <path> instead of stdout.',
   'Examples:',
   '  The command',
   '',
@@ -79,7 +81,8 @@ var args = nopt(
     'strip-comments': Boolean,
     'no-implicit-strip': Boolean,
     'inline-scripts': Boolean,
-    'inline-css': Boolean
+    'inline-css': Boolean,
+    'out-html': String
   },
   {
     'h': ['--help'],
@@ -138,5 +141,11 @@ args.inlineCss = args['inline-css'];
     process.stderr.write(require('util').inspect(err));
     process.exit(1);
   }
-  process.stdout.write(content);
+  if (args['out-html']) {
+      var fd = fs.openSync(args['out-html'], 'w');
+      fs.writeSync(fd, content + "\n");
+      fs.closeSync(fd);
+  } else {
+    process.stdout.write(content);
+  }
 });
diff --git a/lib/vulcan.js b/lib/vulcan.js
index 6a274c5..62ea9c9 100644
--- a/lib/vulcan.js
+++ b/lib/vulcan.js
@@ -140,7 +140,7 @@ Vulcan.prototype = {
     }
     var href = importMeta.href;
     return this.stripExcludes.some(function(r) {
-      return href.search(r) >= 0;
+      return r == href;
     });
   },
 
diff --git a/package.json b/package.json
index d93b3b4..bdcde6c 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "vulcanize",
-  "version": "1.13.1",
+  "version": "1.13.0",
   "description": "Process Web Components into one output file",
   "main": "lib/vulcan.js",
   "bin": {


Test patch:
diff --git a/test/test.js b/test/test.js
index 461dc25..04326a0 100644
--- a/test/test.js
+++ b/test/test.js
@@ -578,23 +578,6 @@ suite('Vulcan', function() {
       process(inputPath, callback, options);
     });
 
-    test('Strip Excludes does not have to be exact', function(done) {
-      var options = {
-        stripExcludes: ['simple-import']
-      };
-
-      var callback = function(err, doc) {
-        if (err) {
-          return done(err);
-        }
-        var imports = dom5.queryAll(doc, excluded);
-        assert.equal(imports.length, 0);
-        done();
-      };
-
-      process(inputPath, callback, options);
-    });
-
     test('Excluded comments are removed', function(done) {
       var options = {
         stripComments: true