mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-26 17:16:11 -05:00
Filter before mapping to avoid returning undefined
If the map function doesn't return anything, the added item is undefined. Avoid this by filtering the array before mapping.
This commit is contained in:
parent
bb70629b6b
commit
ca546552b9
1 changed files with 6 additions and 6 deletions
|
@ -29,13 +29,13 @@ var extraAppRoutes = [
|
|||
*/
|
||||
var getStaticPaths = function (pathToStatic) {
|
||||
var staticPaths = glob.sync(path.resolve(__dirname, pathToStatic));
|
||||
return staticPaths.map(function (pathName) {
|
||||
return staticPaths.filter(function (pathName) {
|
||||
// Exclude view html, resolve everything else in the build
|
||||
if (path.extname(pathName) !== '.html') {
|
||||
// Reduce absolute path to relative paths like '/js'
|
||||
var base = path.dirname(path.resolve(__dirname, pathToStatic));
|
||||
return '^' + pathName.replace(base, '') + (path.extname(pathName) ? '' : '/');
|
||||
}
|
||||
return path.extname(pathName) !== '.html';
|
||||
}).map(function (pathName) {
|
||||
// Reduce absolute path to relative paths like '/js'
|
||||
var base = path.dirname(path.resolve(__dirname, pathToStatic));
|
||||
return '^' + pathName.replace(base, '') + (path.extname(pathName) ? '' : '/');
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue