File tree 1 file changed +6
-3
lines changed
1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,9 @@ var argv = require('yargs')
15
15
. alias ( 'u' , 'use' )
16
16
. array ( 'use' )
17
17
. pkgConf ( 'posthtml' )
18
- . config ( )
18
+ . config ( 'config' , function ( config ) {
19
+ return JSON . parse ( fs . readFileSync ( config , 'utf-8' ) )
20
+ } )
19
21
. alias ( 'c' , 'config' )
20
22
. version ( )
21
23
. alias ( 'v' , 'version' )
@@ -36,10 +38,11 @@ function processing(file, output) {
36
38
// get htmls
37
39
var html = fs . readFileSync ( file , 'utf8' )
38
40
var plugins ;
41
+ var fileConfig = argv . config && JSON . parse ( fs . readFileSync ( argv . config , 'utf-8' ) ) ;
39
42
40
43
if ( argv . autoOff ) {
41
44
var use = argv . use ? argv . use : [ ] ;
42
- var cfg = argv . config ? Object . keys ( require ( path . resolve ( argv . config ) ) ) : [ ] ;
45
+ var cfg = argv . config ? Object . keys ( fileConfig ) : [ ] ;
43
46
plugins = [ ] . concat ( use , cfg ) . map ( ( plugin ) => {
44
47
try {
45
48
return require ( plugin ) ( argv [ plugin ] )
@@ -61,7 +64,7 @@ function processing(file, output) {
61
64
}
62
65
63
66
if ( argv . config ) {
64
- config = Object . assign ( require ( path . resolve ( argv . config ) ) , config )
67
+ config = Object . assign ( fileConfig , config )
65
68
}
66
69
}
67
70
You can’t perform that action at this time.
0 commit comments