Skip to content

Commit

Permalink
Merge pull request #192 from netlify/refactoring/reduce-to-some
Browse files Browse the repository at this point in the history
Small code simplification (`Array.reduce()` -> `Array.some()`)
  • Loading branch information
swyxio authored Sep 5, 2019
2 parents a82873b + aede228 commit b0407d7
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ function haveBabelrc(functionsDir) {

return (
fs.existsSync(path.join(cwd, ".babelrc")) ||
functionsDir.split("/").reduce((foundBabelrc, dir) => {
if (foundBabelrc) return foundBabelrc;

functionsDir.split("/").some(dir => {
const indexOf = functionsDir.indexOf(dir);
const dirToSearch = functionsDir.substr(0, indexOf);

return fs.existsSync(path.join(cwd, dirToSearch, ".babelrc"));
}, false)
})
);
}

Expand Down

0 comments on commit b0407d7

Please sign in to comment.