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

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sw-yx committed Jun 12, 2019
2 parents 65b0d92 + 0eb21d8 commit e760e34
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <command>` runs a shell command within the netlify dev environment
- `netlify functions:create` bootstrap a new function
Expand Down
44 changes: 23 additions & 21 deletions src/utils/serve-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e760e34

Please sign in to comment.