Skip to content

Commit 506f236

Browse files
authored
fix default export issue (#11)
1 parent 5e2ff88 commit 506f236

4 files changed

Lines changed: 10 additions & 9 deletions

File tree

readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ this is consistent with how javascript templates work.
9999
in addition to `${regular}` expressions, you can add in your own 'handlers'
100100

101101
```js
102-
import { addHandler } from '@conjurelabs/dot-template'
102+
import dotTemplate from '@conjurelabs/dot-template'
103103

104-
addHandler({
104+
dotTemplate.addHandler({
105105
// `expressionPrefix` is required
106106
// this example would support `@{expression}`s
107107
expressionPrefix: '@',
@@ -146,7 +146,7 @@ a simple use of the difference between `valueMutator` and `logMutator` is when y
146146
you can support this easily:
147147

148148
```js
149-
addHandler({
149+
dotTemplate.addHandler({
150150
expressionPrefix: '!',
151151
logMutator: () => '<REDACTED>'
152152
})

src/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,15 @@ class Template {
190190
}
191191
}
192192

193-
export default function dotTemplate(path: string) {
193+
function dotTemplate(path: string) {
194194
const template = readFile(path, 'utf8')
195195

196196
return async function prepare(values: Record<string, unknown>, ...tailingArgs: unknown[]) {
197197
return new Template(await template, values, null, ...tailingArgs)
198198
}
199199
}
200200

201-
export function addHandler({
201+
dotTemplate.addHandler = function addHandler({
202202
expressionPrefix,
203203
valueMutator = selfReturnNoOp,
204204
valuesObjectMutator = selfReturnNoOp,
@@ -250,7 +250,8 @@ export function addHandler({
250250
}
251251

252252
// phase 0: replace standard applied values (e.g. `${}`)
253-
addHandler({
253+
dotTemplate.addHandler({
254254
expressionPrefix: standardTemplate
255255
})
256256

257+
export = dotTemplate

test/redactions/redactions.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import dotTemplate, { addHandler } from '../../src/'
1+
import dotTemplate from '../../src/'
22
import { readFile } from 'fs/promises'
33
import path from 'path'
44

55
describe('basic usage', () => {
66
test('value mutator should work as expected', async () => {
7-
addHandler({
7+
dotTemplate.addHandler({
88
expressionPrefix: '!',
99
valueMutator: () => '>>REDACTED<<'
1010
})

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
"moduleResolution": "node",
88
"strict": true,
9-
"esModuleInterop": true,
9+
"esModuleInterop": false,
1010
"skipLibCheck": true,
1111
"allowJs": false,
1212
"allowSyntheticDefaultImports": true,

0 commit comments

Comments
 (0)