Skip to content

Commit

Permalink
Prevent type declaration files to generate pages (#3076)
Browse files Browse the repository at this point in the history
  • Loading branch information
ViliamKopecky authored and KyleAMathews committed Nov 30, 2017
1 parent 8340189 commit 6828aea
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,25 @@ describe(`JavaScript page creator`, () => {
expect(files.filter(file => validatePath(file.path)).length).toEqual(1)
})

it(`filters out files that have TypeScript declaration extensions`, () => {
const files = [
{
path: `something/foo.ts`,
},
{
path: `something/bar.tsx`,
},
{
path: `something/declaration-file.d.ts`,
},
{
path: `something-else/other-declaration-file.d.tsx`,
},
]

expect(files.filter(file => validatePath(file.path)).length).toEqual(2)
})

describe(`create-path`, () => {
it(`should create unix paths`, () => {
const basePath = `/a/`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
const systemPath = require(`path`)

const tsDeclarationExtTest = /\.d\.tsx?$/

module.exports = path => {
// Disallow paths starting with an underscore
// and template-.
// and .d.ts
const parsedPath = systemPath.parse(path)
return (
parsedPath.name.slice(0, 1) !== `_` &&
parsedPath.name.slice(0, 9) !== `template-`
parsedPath.name.slice(0, 9) !== `template-` &&
!tsDeclarationExtTest.test(parsedPath.base)
)
}

0 comments on commit 6828aea

Please sign in to comment.