-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
496481d
commit 1b79806
Showing
7 changed files
with
61 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,36 @@ | ||
import { join, relative, resolve } from 'node:path' | ||
import { join, resolve } from 'node:path' | ||
import { matchGlobs } from '../../modules/graphqlYoga/utils' | ||
import type { NuxtPergel, PergelModuleNames } from '../types/nuxtModule' | ||
import type { NuxtPergel } from '../types/nuxtModule' | ||
|
||
export function globsBuilderWatch( | ||
nuxt: NuxtPergel, | ||
path: string, | ||
folder: string, | ||
ext: string, | ||
) { | ||
const absolutePath = resolve(nuxt.options.rootDir, path) | ||
const relativePath = relative(nuxt.options.rootDir, path) | ||
const dirs = nuxt._pergel.watchDirs | ||
const match = matchGlobs( | ||
absolutePath, | ||
[...dirs.map(({ serverDir }) => { | ||
return join('**', serverDir, '**') | ||
}), ...dirs.map(({ rootModuleDir }) => { | ||
return join('**', rootModuleDir, '**') | ||
})], | ||
) | ||
|
||
const groups = relativePath.match(/pergel\/(?<projectName>[^\/]+)\/(?<moduleName>[^\/]+)/)?.groups | ||
const { projectName, moduleName } = groups || {} | ||
if (!match) { | ||
return { | ||
match: false, | ||
} | ||
} | ||
|
||
const match = matchGlobs(absolutePath, [join('**', folder, '**', `*${ext}`)]) | ||
const { serverDir, projectName, moduleName } = dirs.find(({ serverDir, rootModuleDir }) => { | ||
return match.glob.includes(serverDir) || match.glob.includes(rootModuleDir) | ||
})! | ||
|
||
return { | ||
match, | ||
match: true, | ||
serverDir, | ||
projectName, | ||
moduleName: moduleName as PergelModuleNames, | ||
moduleName, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters