@@ -18,6 +18,18 @@ describe('Load plugins', () => {
1818 '}'
1919 ] . join ( '\n' ) ;
2020
21+ const asyncScript = [
22+ 'async function afunc() {' ,
23+ ' return new Promise(resolve => resolve());' ,
24+ '}' ,
25+ 'await afunc()' ,
26+ 'hexo._script_test = {' ,
27+ ' filename: __filename,' ,
28+ ' dirname: __dirname,' ,
29+ ' module: module,' ,
30+ ' require: require' ,
31+ '}'
32+ ] . join ( '\n' ) ;
2133 function validate ( path ) {
2234 const result = hexo . _script_test ;
2335
@@ -81,6 +93,19 @@ describe('Load plugins', () => {
8193 } ) ;
8294 } ) ;
8395
96+ it ( 'load async plugins' , ( ) => {
97+ const name = 'hexo-async-plugin-test' ;
98+ const path = join ( hexo . plugin_dir , name , 'index.js' ) ;
99+
100+ return Promise . all ( [
101+ createPackageFile ( name ) ,
102+ fs . writeFile ( path , asyncScript )
103+ ] ) . then ( ( ) => loadPlugins ( hexo ) ) . then ( ( ) => {
104+ validate ( path ) ;
105+ return fs . unlink ( path ) ;
106+ } ) ;
107+ } ) ;
108+
84109 it ( 'load scoped plugins' , ( ) => {
85110 const name = '@some-scope/hexo-plugin-test' ;
86111 const path = join ( hexo . plugin_dir , name , 'index.js' ) ;
0 commit comments