File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,7 +15,9 @@ var argv = require('yargs')
1515 . alias ( 'u' , 'use' )
1616 . array ( 'use' )
1717 . pkgConf ( 'posthtml' )
18- . config ( )
18+ . config ( 'config' , function ( config ) {
19+ return JSON . parse ( fs . readFileSync ( config , 'utf-8' ) )
20+ } )
1921 . alias ( 'c' , 'config' )
2022 . version ( )
2123 . alias ( 'v' , 'version' )
@@ -36,10 +38,11 @@ function processing(file, output) {
3638 // get htmls
3739 var html = fs . readFileSync ( file , 'utf8' )
3840 var plugins ;
41+ var fileConfig = argv . config && JSON . parse ( fs . readFileSync ( argv . config , 'utf-8' ) ) ;
3942
4043 if ( argv . autoOff ) {
4144 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 ) : [ ] ;
4346 plugins = [ ] . concat ( use , cfg ) . map ( ( plugin ) => {
4447 try {
4548 return require ( plugin ) ( argv [ plugin ] )
@@ -61,7 +64,7 @@ function processing(file, output) {
6164 }
6265
6366 if ( argv . config ) {
64- config = Object . assign ( require ( path . resolve ( argv . config ) ) , config )
67+ config = Object . assign ( fileConfig , config )
6568 }
6669 }
6770
You can’t perform that action at this time.
0 commit comments