Skip to content

Commit

Permalink
🐛 FIX: fake files
Browse files Browse the repository at this point in the history
  • Loading branch information
jycouet committed Oct 14, 2022
1 parent 23c2059 commit eaff0ab
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@theguild/eslint-config": "^0.1.0",
"@trivago/prettier-plugin-sort-imports": "^3.3.0",
"graphql": "*",
"husky": "^7.0.4",
"prettier": "^2.5.1",
"turbo": "^1.5.4",
"vite": "^3.1.6",
Expand Down
16 changes: 8 additions & 8 deletions packages/houdini-svelte/src/plugin/fsPatch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import filesystem, { Dirent, PathLike } from 'fs'
import { fs, Plugin } from 'houdini'
import { fs, Plugin, h_join } from 'houdini'
import path from 'path'

import {
Expand Down Expand Up @@ -38,7 +38,7 @@ export default (getFramwork: () => Framework) =>
return {
code:
(await fs.readFile(filepath)) ||
(await fs.readFile(path.join(config.projectRoot, filepath))) ||
(await fs.readFile(h_join(config.projectRoot, filepath))) ||
'',
}
}
Expand All @@ -48,7 +48,7 @@ export default (getFramwork: () => Framework) =>
return {
code:
(await fs.readFile(filepath)) ||
(await fs.readFile(path.join(config.projectRoot, filepath))) ||
(await fs.readFile(h_join(config.projectRoot, filepath))) ||
empty_layout,
}
}
Expand Down Expand Up @@ -79,7 +79,7 @@ filesystem.readFileSync = function (fp, options) {
}
}

if (filepath.endsWith(path.join('src', 'routes', '+layout.svelte'))) {
if (filepath.endsWith(h_join('src', 'routes', '+layout.svelte'))) {
try {
return _readFileSync(filepath, options)
} catch {
Expand All @@ -106,9 +106,9 @@ filesystem.statSync = function (filepath: string, options: Parameters<filesystem
// always fake the root +layout.server.js and +layout.svelte
if (
filepath.endsWith('routes/+layout.svelte') ||
filepath.endsWith(path.join('routes', '+layout.svelte')) ||
filepath.endsWith(h_join('routes', '+layout.svelte')) ||
filepath.endsWith('routes/+layout.server.js') ||
filepath.endsWith(path.join('routes', '+layout.server.js'))
filepath.endsWith(h_join('routes', '+layout.server.js'))
) {
return mock
}
Expand Down Expand Up @@ -219,9 +219,9 @@ function virtual_file(name: string, options: Parameters<typeof filesystem.readdi

function is_root_route(filepath: PathLike): boolean {
return (
filepath.toString().endsWith(path.join('src', 'routes')) &&
filepath.toString().endsWith(h_join('src', 'routes')) &&
// ignore the src/routes that exists in the
!filepath.toString().includes(path.join('.svelte-kit', 'types'))
!filepath.toString().includes(h_join('.svelte-kit', 'types'))
)
}

Expand Down
2 changes: 2 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit eaff0ab

Please sign in to comment.