OLD | NEW |
---|---|
(Empty) | |
1 #!/bin/bash | |
2 | |
3 # Copyright 2014 The Chromium Authors. All rights reserved. | |
4 # Use of this source code is governed by a BSD-style license that can be | |
5 # found in the LICENSE file. | |
6 | |
7 set -e | |
8 | |
9 if [ "$#" -ne 0 ] | |
10 then | |
11 echo "Usage: $0" | |
12 echo "" | |
13 echo "Extracts inline scripts from Polymer HTML files to external JS files." | |
14 echo "Prints the names of created JS files to the standard output." | |
15 exit 1 | |
16 fi | |
17 | |
18 if [ -e "components-extracted" ] | |
19 then | |
20 echo "ERROR: 'components-extracted' already exists. Please remove it before" \ | |
21 "running the script." 1>&2 | |
22 exit 1 | |
23 fi | |
24 | |
25 cp -r components components-extracted | |
26 find components-extracted -name "*.html" \ | |
27 -not -path "*/demos/*" \ | |
28 -not -name "demo*.html" \ | |
29 -not -name "index.html" \ | |
30 -not -name "metadata.html" | \ | |
31 xargs grep -l "<script>" | \ | |
32 while read original_html | |
raymes
2014/09/23 00:27:56
original_html->original_html_filename
dzhioev (left Google)
2014/09/23 09:48:53
Done.
| |
33 do | |
34 dir=$(dirname "$original_html") | |
35 name=$(basename "$original_html" .html) | |
36 | |
37 html_without_js="$dir/$name-extracted.html" | |
38 extracted_js="$dir/$name-extracted.js" | |
39 vulcanize -o "$html_without_js" --csp --config vulcanize_config.json \ | |
40 "$original_html" 1>&2 | |
41 mv "$html_without_js" "$original_html" | |
42 echo "$extracted_js" | |
43 done | |
OLD | NEW |