Verified Commit 03f754db authored by Aral Balkan's avatar Aral Balkan
Browse files

Fix so function can be called with different directory roots

parent 360196b0
const fs = require('fs')
const path = require('path')
let directoryRoot = null
function routes (directory) {
function routes (directory, directoryRoot = null) {
let _routes = []
if (directoryRoot === null) directoryRoot = new RegExp(`^.*${directory.replace('.', '\\.')}`)
......@@ -20,7 +18,7 @@ function routes (directory) {
return
}
// Recurse.
_routes = _routes.concat(routes(path.join(directory, file.name)))
_routes = _routes.concat(routes(path.join(directory, file.name), directoryRoot))
} else if (file.isFile() && file.name.endsWith('.js')) {
//
// File.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment