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

Side by Side Diff: third_party/node/patch_vulcanize.diff

Issue 2643723005: WebUI: Apply local patch to vulcanize. (Closed)
Patch Set: Created 3 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 unified diff | Download patch
OLDNEW
(Empty)
1 diff --git a/bin/vulcanize b/bin/vulcanize
2 index 956b2bc..ad8b29d 100755
3 --- a/bin/vulcanize
4 +++ b/bin/vulcanize
5 @@ -35,6 +35,7 @@ var help = [
6 ' --redirect <uri>|<path>: Takes an argument in the form of URI|PATH where u rl is a URI composed of a protocol, hostname, and path and PATH is a local files ystem path to replace the matched URI part with. Multiple redirects may be speci fied; the earliest ones have the highest priority.',
7 ' --no-implicit-strip: DANGEROUS! Avoid stripping imports of the transitive dependencies of imports specified with `--exclude`. May result in duplicate java script inlining.',
8 ' --out-html <path>: If specified, output will be written to <path> instead of stdout.',
9 + ' --out-request-list <path>: Writes a list of request URLs required to vulca nize <html file> to <path> on success.',
10 'Examples:',
11 ' The command',
12 '',
13 @@ -82,7 +83,8 @@ var args = nopt(
14 'no-implicit-strip': Boolean,
15 'inline-scripts': Boolean,
16 'inline-css': Boolean,
17 - 'out-html': String
18 + 'out-html': String,
19 + 'out-request-list': String
20 },
21 {
22 'h': ['--help'],
23 @@ -126,15 +128,23 @@ args.implicitStrip = !args['no-implicit-strip'];
24 args.inlineScripts = args['inline-scripts'];
25 args.inlineCss = args['inline-css'];
26
27 -(new vulcan(args)).process(target, function(err, content) {
28 +var vulcanize = new vulcan(args);
29 +vulcanize.process(target, function(err, content) {
30 if (err) {
31 process.stderr.write(require('util').inspect(err));
32 process.exit(1);
33 }
34 +
35 + if (args['out-request-list']) {
36 + var urls = Object.keys(vulcanize.loader.requests).filter(function(request) {
37 + // Filter out excluded URLs.
38 + return !vulcanize.isExcludedHref(request);
39 + });
40 + fs.writeFileSync(args['out-request-list'], urls.join('\n') + '\n');
41 + }
42 +
43 if (args['out-html']) {
44 - var fd = fs.openSync(args['out-html'], 'w');
45 - fs.writeSync(fd, content + "\n");
46 - fs.closeSync(fd);
47 + fs.writeFileSync(args['out-html'], content + '\n');
48 } else {
49 process.stdout.write(content);
50 }
51 diff --git a/lib/constants.js b/lib/constants.js
52 index 21e1380..b6a353a 100644
53 --- a/lib/constants.js
54 +++ b/lib/constants.js
55 @@ -13,6 +13,6 @@ module.exports = {
56 ABS_URL: /(^\/)|(^#)|(^[\w-\d]*:)/,
57 URL: /url\([^)]*\)/g,
58 URL_ATTR: ['href', 'src', 'action', 'style', 'assetpath'],
59 - URL_TEMPLATE: '{{.*}}|\\[\\[.*\\]\\]',
60 + URL_TEMPLATE: '{{.*}}|\\[\\[.*\\]\\]|\\$i18n[^{]*{[^}]*}',
61 OLD_POLYMER: 'This version of vulcanize is not compatible with Polymer < 0.8. Please use vulcanize 0.7.x.'
62 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698