File tree Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -5,10 +5,17 @@ jest.mock(`fs`, () => {
55 }
66} )
77jest . mock ( `recursive-readdir` , ( ) => jest . fn ( ) )
8+ jest . mock ( `gatsby-cli/lib/reporter` , ( ) => {
9+ return {
10+ panic : jest . fn ( ) ,
11+ }
12+ } )
813
914const fs = require ( `fs` )
1015const readdir = require ( `recursive-readdir` )
1116
17+ const reporter = require ( `gatsby-cli/lib/reporter` )
18+
1219const {
1320 OPTION_DEFAULT_HTML ,
1421 OPTION_DEFAULT_REDIRECT_TEMPLATE_PATH ,
@@ -20,6 +27,7 @@ const createPagesParams = {
2027 actions : {
2128 createPage,
2229 } ,
30+ reporter,
2331}
2432
2533describe ( `gatsby-remark-code-repls` , ( ) => {
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ const {
1212} = require ( `./constants` )
1313
1414exports . createPages = async (
15- { actions } ,
15+ { actions, reporter } ,
1616 {
1717 directory = OPTION_DEFAULT_LINK_TEXT ,
1818 externals = [ ] ,
@@ -27,11 +27,11 @@ exports.createPages = async (
2727 const { createPage } = actions
2828
2929 if ( ! fs . existsSync ( directory ) ) {
30- throw Error ( `Invalid REPL directory specified: "${ directory } "` )
30+ reporter . panic ( `Invalid REPL directory specified: "${ directory } "` )
3131 }
3232
3333 if ( ! fs . existsSync ( redirectTemplate ) ) {
34- throw Error (
34+ reporter . panic (
3535 `Invalid REPL redirectTemplate specified: "${ redirectTemplate } "`
3636 )
3737 }
@@ -75,7 +75,12 @@ exports.createPages = async (
7575 }
7676 } )
7777 } catch ( error ) {
78- // retrow errors upstream
79- throw error
78+ reporter . panic (
79+ `
80+ Error in gatsby-remark-code-repls plugin: cannot read directory ${ directory } .
81+ More details can be found in the error reporting below.
82+ ` ,
83+ error
84+ )
8085 }
8186}
You can’t perform that action at this time.
0 commit comments