@@ -56,27 +56,29 @@ function buildClientContext(headers) {
56
56
57
57
function createHandler ( dir ) {
58
58
const functions = { } ;
59
- fs . readdirSync ( dir ) . forEach ( file => {
60
- if ( dir === "node_modules" ) {
61
- return ;
62
- }
63
- const functionPath = path . resolve ( path . join ( dir , file ) ) ;
64
- const handlerPath = findHandler ( functionPath ) ;
65
- if ( ! handlerPath ) {
66
- return ;
67
- }
68
- if ( path . extname ( functionPath ) === ".js" ) {
69
- functions [ file . replace ( / \. j s $ / , "" ) ] = {
70
- functionPath,
71
- moduleDir : findModuleDir ( functionPath )
72
- } ;
73
- } else if ( fs . lstatSync ( functionPath ) . isDirectory ( ) ) {
74
- functions [ file ] = {
75
- functionPath : handlerPath ,
76
- moduleDir : findModuleDir ( functionPath )
77
- } ;
78
- }
79
- } ) ;
59
+ if ( fs . existsSync ( dir ) ) {
60
+ fs . readdirSync ( dir ) . forEach ( file => {
61
+ if ( dir === "node_modules" ) {
62
+ return ;
63
+ }
64
+ const functionPath = path . resolve ( path . join ( dir , file ) ) ;
65
+ const handlerPath = findHandler ( functionPath ) ;
66
+ if ( ! handlerPath ) {
67
+ return ;
68
+ }
69
+ if ( path . extname ( functionPath ) === ".js" ) {
70
+ functions [ file . replace ( / \. j s $ / , "" ) ] = {
71
+ functionPath,
72
+ moduleDir : findModuleDir ( functionPath )
73
+ } ;
74
+ } else if ( fs . lstatSync ( functionPath ) . isDirectory ( ) ) {
75
+ functions [ file ] = {
76
+ functionPath : handlerPath ,
77
+ moduleDir : findModuleDir ( functionPath )
78
+ } ;
79
+ }
80
+ } ) ;
81
+ }
80
82
81
83
const clearCache = action => path => {
82
84
console . log ( `${ NETLIFYDEVLOG } ${ path } ${ action } , reloading...` ) ; // eslint-disable-line no-console
0 commit comments