1- ' use strict' ;
1+ " use strict" ;
22
3- const { mergeWith } = require ( ' lodash' ) ;
4- const { join } = require ( ' path' ) ;
5- const { readFileSync } = require ( 'fs' ) ;
6- const { Cache } = require ( ' hexo-util' ) ;
3+ const { mergeWith } = require ( " lodash" ) ;
4+ const { join } = require ( " path" ) ;
5+ const { readFileSync } = require ( "fs" ) ;
6+ const { Cache } = require ( " hexo-util" ) ;
77const cache = new Cache ( ) ;
88
99const utils = {
1010 htmlTag : ( tag , attrs , text ) => {
11- let attrText = '' ;
11+ let attrText = "" ;
1212 if ( attrs ) {
13- attrText = ' ' + Object . keys ( attrs ) . map ( key => `${ key } ="${ attrs [ key ] } "` ) . join ( ' ' ) ;
13+ attrText =
14+ " " +
15+ Object . keys ( attrs )
16+ . map ( ( key ) => `${ key } ="${ attrs [ key ] } "` )
17+ . join ( " " ) ;
1418 }
15- let end = '/>' ;
19+ let end = "/>" ;
1620 if ( text ) {
1721 end = `>${ text } </${ tag } >` ;
1822 }
@@ -25,25 +29,28 @@ const utils = {
2529 }
2630 } ) ;
2731 } ,
28- readJsonFile : path => {
32+ readJsonFile : ( path ) => {
2933 return cache . apply ( path , ( ) => {
30- const data = readFileSync ( path , ' utf-8' ) ;
34+ const data = readFileSync ( path , " utf-8" ) ;
3135 return JSON . parse ( data ) ;
3236 } ) ;
3337 } ,
34- deps : dir => utils . readJsonFile ( join ( dir , ' package.json' ) ) . dependencies ,
35- loadUtil : hexo => {
38+ deps : ( dir ) => utils . readJsonFile ( join ( dir , " package.json" ) ) . dependencies ,
39+ loadUtil : ( hexo ) => {
3640 const deps = utils . deps ( hexo . base_dir ) ;
37- return name => {
41+ return ( name ) => {
3842 if ( ! deps [ name ] ) {
39- return hexo . loadPlugin ( hexo . resolvePlugin ( name ) ) ;
43+ return hexo . loadPlugin (
44+ hexo . resolvePlugin ( name , hexo . base_dir ) ,
45+ hexo . base_dir ,
46+ ) ;
4047 }
4148 } ;
4249 } ,
43- isHexoRendererMarkedMini : hexo => {
50+ isHexoRendererMarkedMini : ( hexo ) => {
4451 const deps = utils . deps ( hexo . base_dir ) ;
45- return deps [ ' hexo-renderer-marked-mini' ] ;
46- }
52+ return deps [ " hexo-renderer-marked-mini" ] ;
53+ } ,
4754} ;
4855
4956module . exports = utils ;
0 commit comments