Last active
January 10, 2021 00:31
-
-
Save MaikelVeen/7c3563968dddb72f0818ce32c59b7109 to your computer and use it in GitHub Desktop.
GetPathsFromBuildFolder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const GetPathsFromBuildFolder = (dir: string, urlList: Array<Url>, host: string, basePath: string): Array<Url> => { | |
const files: string[] = fs.readdirSync(dir); | |
urlList = urlList || []; | |
files.forEach((file) => { | |
if (fs.statSync(dir + file).isDirectory()) { | |
urlList = GetPathsFromBuildFolder(dir + file + '/', urlList, host, basePath); | |
} else { | |
if (path.extname(file) == '.json') { | |
let route = path.join(dir + file.substring(0, file.length - 5)); | |
route = route.replace(basePath, '/'); | |
urlList.push({ host: host, route: route }); | |
} | |
} | |
}); | |
return urlList; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment