Skip to content
This repository was archived by the owner on Sep 12, 2019. It is now read-only.

Commit e760e34

Browse files
author
sw-yx
committed
2 parents 65b0d92 + 0eb21d8 commit e760e34

File tree

2 files changed

+25
-21
lines changed

2 files changed

+25
-21
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ This is how we pull down your build environment variables and manage your addons
4343

4444
## Usage
4545

46+
*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.*
47+
4648
- `netlify dev` start a local dev server for the build tool you're using
4749
- `netlify dev:exec <command>` runs a shell command within the netlify dev environment
4850
- `netlify functions:create` bootstrap a new function

src/utils/serve-functions.js

+23-21
Original file line numberDiff line numberDiff line change
@@ -56,27 +56,29 @@ function buildClientContext(headers) {
5656

5757
function createHandler(dir) {
5858
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(/\.js$/, "")] = {
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(/\.js$/, "")] = {
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+
}
8082

8183
const clearCache = action => path => {
8284
console.log(`${NETLIFYDEVLOG} ${path} ${action}, reloading...`); // eslint-disable-line no-console

0 commit comments

Comments
 (0)