Skip to content

Commit

Permalink
0.2.1: getBinaryNames
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj committed Aug 28, 2023
1 parent b45231f commit 7821f5f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@libreservice/micro-plum",
"version": "0.2.0",
"version": "0.2.1",
"main": "dist/index.js",
"type": "module",
"files": [
Expand Down
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ export {
GitHubDownloader,
JsDelivrDownloader
} from './downloader'

export {
getBinaryNames
} from './parser'
2 changes: 1 addition & 1 deletion src/parser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { parseDict } from './dictParser'
export { parseLua } from './luaParser'
export { parseOpenCC } from './openccParser'
export { parseSchema } from './schemaParser'
export { parseSchema, getBinaryNames } from './schemaParser'
10 changes: 10 additions & 0 deletions src/schemaParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,13 @@ export function parseSchema (schema: object): string[][] {
}
return result.map(expandLua)
}

export function getBinaryNames (schema: { translator?:
{ dictionary: string, prism?: string }
}) {
if (schema.translator) {
const { dictionary, prism } = schema.translator
return { dict: dictionary, prism: prism || dictionary }
}
return {}
}
7 changes: 7 additions & 0 deletions test/test-parser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { expect, it } from 'vitest'
import {
parseOpenCC,
parseSchema,
getBinaryNames,
parseDict,
parseLua
} from '../src/parser'
Expand Down Expand Up @@ -49,6 +50,12 @@ it('Parse schema', () => {
}
})

it('getBinaryNames', () => {
const obj = loadYaml('base.schema.yaml')
expect(getBinaryNames(obj)).toEqual({ dict: 'parent', prism: 'parent' })
expect(getBinaryNames({})).toEqual({})
})

const dictCases = {
'parent.dict.yaml': [
['my-essay.txt'],
Expand Down

0 comments on commit 7821f5f

Please sign in to comment.