1- 'use strict'
1+ 'use strict' ;
22
33const fs = require ( 'fs' ) ;
44const path = require ( 'path' ) ;
@@ -8,17 +8,15 @@ const {match} = require('posthtml/lib/api');
88const expressions = require ( 'posthtml-expressions' ) ;
99
1010module . exports = ( options = { } ) => {
11- options . root = options . root ?
12- path . resolve ( options . root ) :
13- process . cwd ( ) ;
11+ options . root = options . root ? path . resolve ( options . root ) : process . cwd ( ) ;
1412 options . encoding = options . encoding || 'utf-8' ;
1513
1614 return function posthtmlInclude ( tree ) {
1715 const cwd = options . cwd ?
1816 path . resolve ( options . cwd ) :
1917 ( tree . options . from ?
2018 path . dirname ( path . resolve ( tree . options . from ) ) :
21- process . cwd ( ) )
19+ process . cwd ( ) ) ;
2220
2321 tree . parser = tree . parser || parser ;
2422 tree . match = tree . match || match ;
@@ -28,23 +26,29 @@ module.exports = (options = {}) => {
2826 let content ;
2927 let subtree ;
3028 let source ;
31- let posthtmlExpressionsOptions = options . posthtmlExpressionsOptions || { locals : false } ;
29+ let posthtmlExpressionsOptions = options . posthtmlExpressionsOptions || {
30+ locals : false
31+ } ;
3232 if ( options . delimiters ) {
3333 posthtmlExpressionsOptions . delimiters = options . delimiters ;
3434 }
3535
3636 if ( src ) {
3737 src = path . isAbsolute ( src ) ?
3838 path . join ( options . root , src ) :
39- path . resolve ( cwd , src )
39+ path . resolve ( cwd , src ) ;
4040 source = fs . readFileSync ( src , options . encoding ) ;
4141
4242 try {
43- const localsRaw = node . attrs . locals || ( node . content ? node . content . join ( ) . replace ( / \n / g, '' ) : false ) ;
43+ const localsRaw =
44+ node . attrs . locals ||
45+ ( node . content ? node . content . join ( ) . replace ( / \n / g, '' ) : false ) ;
4446 const localsJson = JSON . parse ( localsRaw ) ;
4547 posthtmlExpressionsOptions = {
4648 ...posthtmlExpressionsOptions ,
47- locals : posthtmlExpressionsOptions . locals ? Object . assign ( posthtmlExpressionsOptions . locals , localsJson ) : localsJson
49+ locals : posthtmlExpressionsOptions . locals ?
50+ Object . assign ( posthtmlExpressionsOptions . locals , localsJson ) :
51+ localsJson
4852 } ;
4953 } catch { }
5054
@@ -65,7 +69,9 @@ module.exports = (options = {}) => {
6569 subtree . match = tree . match ;
6670 subtree . parser = tree . parser ;
6771 subtree . messages = tree . messages ;
68- content = source . includes ( 'include' ) ? posthtmlInclude ( subtree ) : subtree ;
72+ content = source . includes ( 'include' ) ?
73+ posthtmlInclude ( subtree ) :
74+ subtree ;
6975
7076 if ( tree . messages ) {
7177 tree . messages . push ( {
0 commit comments