diff --git a/README.md b/README.md index 375519a..1c24851 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,8 @@ This is how we pull down your build environment variables and manage your addons ## Usage +*Watch [a 10 minute intro](https://www.youtube.com/watch?v=pIOOJD4z-Qo&feature=youtu.be) video on how to use Netlify Dev on your project.* + - `netlify dev` start a local dev server for the build tool you're using - `netlify dev:exec ` runs a shell command within the netlify dev environment - `netlify functions:create` bootstrap a new function diff --git a/src/utils/serve-functions.js b/src/utils/serve-functions.js index 7407854..e321d10 100644 --- a/src/utils/serve-functions.js +++ b/src/utils/serve-functions.js @@ -56,27 +56,29 @@ function buildClientContext(headers) { function createHandler(dir) { const functions = {}; - fs.readdirSync(dir).forEach(file => { - if (dir === "node_modules") { - return; - } - const functionPath = path.resolve(path.join(dir, file)); - const handlerPath = findHandler(functionPath); - if (!handlerPath) { - return; - } - if (path.extname(functionPath) === ".js") { - functions[file.replace(/\.js$/, "")] = { - functionPath, - moduleDir: findModuleDir(functionPath) - }; - } else if (fs.lstatSync(functionPath).isDirectory()) { - functions[file] = { - functionPath: handlerPath, - moduleDir: findModuleDir(functionPath) - }; - } - }); + if (fs.existsSync(dir)) { + fs.readdirSync(dir).forEach(file => { + if (dir === "node_modules") { + return; + } + const functionPath = path.resolve(path.join(dir, file)); + const handlerPath = findHandler(functionPath); + if (!handlerPath) { + return; + } + if (path.extname(functionPath) === ".js") { + functions[file.replace(/\.js$/, "")] = { + functionPath, + moduleDir: findModuleDir(functionPath) + }; + } else if (fs.lstatSync(functionPath).isDirectory()) { + functions[file] = { + functionPath: handlerPath, + moduleDir: findModuleDir(functionPath) + }; + } + }); + } const clearCache = action => path => { console.log(`${NETLIFYDEVLOG} ${path} ${action}, reloading...`); // eslint-disable-line no-console