@@ -38,6 +38,9 @@ program
38
38
"--roman [method]" ,
39
39
'Romanize identifiers. The method can be "pinyin", "baxter" or "unicode"'
40
40
)
41
+ . option ( "--strict" , "Enable static typechecking" )
42
+ . option ( "--allowHttp" , "Allow to import from http" )
43
+ . option ( "--dir <path>" , "Directory to importing from, seprates with comma(,)" )
41
44
. option ( "--outputHanzi" , "Convert output to hanzi" , true )
42
45
. option ( "--log <file>" , "Save log to file" )
43
46
. option ( "--title <title>" , "Override title in rendering" )
@@ -107,25 +110,35 @@ function preprocess() {
107
110
108
111
function getCompiled ( ) {
109
112
const source = getSource ( ) ;
110
- const importPaths = getImportPaths ( ) ;
111
- // console.log(importPaths)
112
113
113
- return compile ( program . lang , source , {
114
+ return compile ( source , {
115
+ ...getCompileOptions ( )
116
+ } ) ;
117
+ }
118
+
119
+ function getImportPaths ( ) {
120
+ const pathes = [ ] ;
121
+ if ( program . dir ) {
122
+ pathes . push ( ...program . dir . split ( "," ) ) ;
123
+ }
124
+ pathes . push ( ...program . files . map ( file => path . resolve ( path . dirname ( file ) ) ) ) ;
125
+ pathes . push ( path . resolve ( "." ) ) ;
126
+ return Array . from ( new Set ( pathes ) ) ;
127
+ }
128
+
129
+ function getCompileOptions ( ) {
130
+ return {
131
+ lang : program . lang ,
114
132
romanizeIdentifiers : program . roman ,
133
+ strict : ! ! program . strict ,
134
+ allowHttp : ! ! program . allowHttp ,
135
+ importPaths : getImportPaths ( ) ,
115
136
logCallback : logHandler ( program . log , "a" ) ,
116
137
errorCallback : function ( x ) {
117
138
console . error ( x ) ;
118
139
process . exit ( ) ;
119
- } ,
120
- importPaths
121
- } ) ;
122
- }
123
-
124
- function getImportPaths ( ) {
125
- const dir = new Set (
126
- program . files . map ( file => path . resolve ( path . dirname ( file ) ) )
127
- ) ;
128
- return [ ...dir , path . resolve ( "." ) ] ;
140
+ }
141
+ } ;
129
142
}
130
143
131
144
function resolvePath ( x ) {
0 commit comments