Skip to content

Commit

Permalink
update pack-resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
PssbleTrngle committed Dec 21, 2023
1 parent f50a46d commit b11dce9
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"ts-jest": "^29.1.1"
},
"dependencies": {
"@pssbletrngle/pack-resolver": "^1.3.0",
"@pssbletrngle/pack-resolver": "^1.4.0",
"@pssbletrngle/resource-merger": "^1.2.4",
"@types/command-line-usage": "^5.0.4",
"@types/minimatch": "^3.0.5",
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion src/loader/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export abstract class JsonLoader<T> implements RegistryProvider<T> {
}

readonly accept: AcceptorWithLoader = (logger, path, content) => {
const match = /(data|assets)[\\/](?<namespace>[\w-]+)[\\/]\w+[\\/](?<rest>[\w-\\/]+).json/.exec(path)
const match = /(data|assets)\/(?<namespace>[\w-]+)\/\w+\/(?<rest>[\w-/]+).json/.exec(path)
if (!match?.groups) return false

const { namespace, rest } = match.groups
Expand Down
4 changes: 2 additions & 2 deletions src/loader/registry/dump.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ export default class RegistryDumpLoader implements RegistryLookup {
}

private registryOf(registry: RegistryId) {
return this.registry.getOrPut(registry.replaceAll('\\', '/'), () => new Set<NormalizedId>())
return this.registry.getOrPut(registry, () => new Set<NormalizedId>())
}

private readonly accept: AcceptorWithLoader = (logger, path, content) => {
const match = /(?<registry>[\w-\\/]+)[\\/][\w-]+.json/.exec(path)
const match = /(?<registry>[\w-/]+)\/[\w-]+.json/.exec(path)
if (!match?.groups) return false

const { registry } = match.groups
Expand Down
2 changes: 1 addition & 1 deletion src/loader/tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default class TagsLoader implements TagRegistryHolder {
}

private parsePath(input: string) {
const match = /data[\\/](?<namespace>[\w-]+)[\\/]tags[\\/](?<rest>[\w-\\/]+).json/.exec(input)
const match = /data\/(?<namespace>[\w-]+)\/tags\/(?<rest>[\w-/]+).json/.exec(input)
if (!match?.groups) return null

const { namespace, rest } = match.groups
Expand Down
6 changes: 1 addition & 5 deletions test/warnings.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import setupLoader from './shared/loaderSetup.js'
import createTestAcceptor from './mock/TestAcceptor.js'
import { join } from 'path'

const { logger, loader } = setupLoader({ include: ['data/*/recipes/**/*.json'], from: 'test/resources/failing' })

Expand All @@ -13,9 +12,6 @@ describe('tests regarding error logging', () => {

await loader.emit(acceptor)

expect(logger.warn).toHaveBeenCalledWith(
`${join('data', 'example', 'recipes', 'incorrectResult.json')} -> unknown result shape`,
120
)
expect(logger.warn).toHaveBeenCalledWith(`data/example/recipes/incorrectResult.json -> unknown result shape`, 120)
})
})

0 comments on commit b11dce9

Please sign in to comment.