Skip to content

Commit

Permalink
Merge pull request #62 from LumaKernel/ext
Browse files Browse the repository at this point in the history
fix: check file extensions
  • Loading branch information
solufa authored Feb 10, 2021
2 parents 50a8da5 + d12843b commit 321dae2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions servers/basic/entity/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Entities

## Task

blah blah
Empty file.
6 changes: 3 additions & 3 deletions src/createText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@ export class ${getFileName(e)} {
(e, i) =>
`\nimport { ${getFileName(e)} as Entity${i} } from '${e
.replace(inputDir, '.')
.replace('.ts', '')}'`
.replace(/\.(?:ts|js)$/, '')}'`
)
.join('')}${migrations
.map((m, i) => {
const names = getFileName(m).split('-')
return `\nimport { ${names[1]}${names[0]} as Migration${i} } from '${m
.replace(inputDir, '.')
.replace('.ts', '')}'`
.replace(/\.(?:ts|js)$/, '')}'`
})
.join('')}${subscribers
.map(
(s, i) =>
`\nimport { ${getFileName(s)} as Subscriber${i} } from '${s
.replace(inputDir, '.')
.replace('.ts', '')}'`
.replace(/\.(?:ts|js)$/, '')}'`
)
.join('')}`

Expand Down
4 changes: 3 additions & 1 deletion src/listFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export const listFiles = (targetDir: string): string[] =>
fs.readdirSync(targetDir, { withFileTypes: true }).reduce<string[]>((prev, dirent) => {
const target = path.posix.join(targetDir, dirent.name)
return dirent.isFile()
? [...prev, targetDir.startsWith('.') ? `./${target}` : target]
? target.match(/\.(?:ts|js)$/)
? [...prev, targetDir.startsWith('.') ? `./${target}` : target]
: prev
: [...prev, ...listFiles(target)]
}, [])

0 comments on commit 321dae2

Please sign in to comment.