Skip to content

Commit

Permalink
add an api that gives higher priority options
Browse files Browse the repository at this point in the history
  • Loading branch information
Toshiya Saito committed Oct 30, 2023
1 parent 644652d commit 631d9c1
Show file tree
Hide file tree
Showing 8 changed files with 2,748 additions and 903 deletions.
13 changes: 10 additions & 3 deletions crates/uroborosql-fmt-napi/__test__/index.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import test from 'ava'

import { sum } from '../index.js'
import { runfmtWithSettings } from '../index.js'

test('sum from native', (t) => {
t.is(sum(1, 2), 3)
test('format with settings', (t) => {
const src = 'select A from B'
const settings = {
keyword_case: 'upper',
identifier_case: 'lower',
complement_alias: false,
}
const dst = runfmtWithSettings(src, JSON.stringify(settings), null)
t.is(dst, 'SELECT\n\ta\nFROM\n\tb\n')
})
1 change: 1 addition & 0 deletions crates/uroborosql-fmt-napi/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/* auto-generated by NAPI-RS */

export function runfmt(input: string, configPath?: string | undefined | null): string
export function runfmtWithSettings(input: string, settingsJson: string, configPath?: string | undefined | null): string
3 changes: 2 additions & 1 deletion crates/uroborosql-fmt-napi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ if (!nativeBinding) {
throw new Error(`Failed to load native binding`)
}

const { runfmt } = nativeBinding
const { runfmt, runfmtWithSettings } = nativeBinding

module.exports.runfmt = runfmt
module.exports.runfmtWithSettings = runfmtWithSettings
Loading

0 comments on commit 631d9c1

Please sign in to comment.