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:
Ray Schamp 2016-05-17 13:49:03 -04:00
parent bb70629b6b
commit ca546552b9

View file

@ -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) ? '' : '/');
});
};