Skip to content

Commit

Permalink
fix default export issue (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmarshall authored Apr 22, 2023
1 parent 5e2ff88 commit 506f236
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ this is consistent with how javascript templates work.
in addition to `${regular}` expressions, you can add in your own 'handlers'

```js
import { addHandler } from '@conjurelabs/dot-template'
import dotTemplate from '@conjurelabs/dot-template'

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

```js
addHandler({
dotTemplate.addHandler({
expressionPrefix: '!',
logMutator: () => '<REDACTED>'
})
Expand Down
7 changes: 4 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,15 @@ class Template {
}
}

export default function dotTemplate(path: string) {
function dotTemplate(path: string) {
const template = readFile(path, 'utf8')

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

export function addHandler({
dotTemplate.addHandler = function addHandler({
expressionPrefix,
valueMutator = selfReturnNoOp,
valuesObjectMutator = selfReturnNoOp,
Expand Down Expand Up @@ -250,7 +250,8 @@ export function addHandler({
}

// phase 0: replace standard applied values (e.g. `${}`)
addHandler({
dotTemplate.addHandler({
expressionPrefix: standardTemplate
})

export = dotTemplate
4 changes: 2 additions & 2 deletions test/redactions/redactions.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import dotTemplate, { addHandler } from '../../src/'
import dotTemplate from '../../src/'
import { readFile } from 'fs/promises'
import path from 'path'

describe('basic usage', () => {
test('value mutator should work as expected', async () => {
addHandler({
dotTemplate.addHandler({
expressionPrefix: '!',
valueMutator: () => '>>REDACTED<<'
})
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

"moduleResolution": "node",
"strict": true,
"esModuleInterop": true,
"esModuleInterop": false,
"skipLibCheck": true,
"allowJs": false,
"allowSyntheticDefaultImports": true,
Expand Down

0 comments on commit 506f236

Please sign in to comment.