@@ -17,35 +17,12 @@ var URL_TEMPLATE = '{{.*}}';
1717var import_buffer = [ ] ;
1818var imports_before_polymer = [ ] ;
1919var read = { } ;
20+ var options = { } ;
2021
21- var options = nopt (
22- {
23- 'output' : path ,
24- 'input' : path ,
25- 'verbose' : Boolean ,
26- 'csp' : Boolean ,
27- 'inline' : Boolean
28- } ,
29- {
30- 'o' : [ '--output' ] ,
31- 'i' : [ '--input' ] ,
32- 'v' : [ '--verbose' ]
33- }
34- ) ;
35-
36- if ( ! options . input ) {
37- console . error ( 'No input file given!' ) ;
38- process . exit ( 1 ) ;
22+ function setOptions ( optHash ) {
23+ options = optHash ;
3924}
4025
41- var DEFAULT_OUTPUT = 'vulcanized.html' ;
42- if ( ! options . output ) {
43- console . warn ( 'Default output to vulcanized.html' + ( options . csp ? ' and vulcanized.js' : '' ) + ' in the input directory.' ) ;
44- options . output = path . resolve ( path . dirname ( options . input ) , DEFAULT_OUTPUT ) ;
45- }
46-
47- var outputDir = path . dirname ( options . output ) ;
48-
4926function resolvePaths ( $ , input , output ) {
5027 var assetPath = path . relative ( output , input ) ;
5128 assetPath = assetPath . split ( path . sep ) . join ( '/' ) + '/' ;
@@ -124,7 +101,7 @@ function concat(filename) {
124101 var dir = path . dirname ( filename ) ;
125102 processImports ( $ , dir ) ;
126103 inlineSheets ( $ , dir ) ;
127- resolvePaths ( $ , dir , outputDir ) ;
104+ resolvePaths ( $ , dir , options . outputDir ) ;
128105 import_buffer . push ( $ . html ( ) ) ;
129106 } else {
130107 if ( options . verbose ) {
@@ -248,4 +225,5 @@ function handleMainDocument() {
248225 fs . writeFileSync ( options . output , outhtml , 'utf8' ) ;
249226}
250227
251- handleMainDocument ( ) ;
228+ exports . processDocument = handleMainDocument ;
229+ exports . setOptions = setOptions ;
0 commit comments