From 506f2369e9990fa877a6677bcb211985c89416c3 Mon Sep 17 00:00:00 2001 From: Tim Marshall Date: Sat, 22 Apr 2023 17:51:39 -0500 Subject: [PATCH] fix default export issue (#11) --- readme.md | 6 +++--- src/index.ts | 7 ++++--- test/redactions/redactions.test.ts | 4 ++-- tsconfig.json | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/readme.md b/readme.md index 91a6e14..7281c25 100644 --- a/readme.md +++ b/readme.md @@ -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: '@', @@ -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: () => '' }) diff --git a/src/index.ts b/src/index.ts index 5e9137a..42bb909 100644 --- a/src/index.ts +++ b/src/index.ts @@ -190,7 +190,7 @@ class Template { } } -export default function dotTemplate(path: string) { +function dotTemplate(path: string) { const template = readFile(path, 'utf8') return async function prepare(values: Record, ...tailingArgs: unknown[]) { @@ -198,7 +198,7 @@ export default function dotTemplate(path: string) { } } -export function addHandler({ +dotTemplate.addHandler = function addHandler({ expressionPrefix, valueMutator = selfReturnNoOp, valuesObjectMutator = selfReturnNoOp, @@ -250,7 +250,8 @@ export function addHandler({ } // phase 0: replace standard applied values (e.g. `${}`) -addHandler({ +dotTemplate.addHandler({ expressionPrefix: standardTemplate }) +export = dotTemplate diff --git a/test/redactions/redactions.test.ts b/test/redactions/redactions.test.ts index b7432e9..313c508 100644 --- a/test/redactions/redactions.test.ts +++ b/test/redactions/redactions.test.ts @@ -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<<' }) diff --git a/tsconfig.json b/tsconfig.json index f64dc06..87dd1b8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,7 @@ "moduleResolution": "node", "strict": true, - "esModuleInterop": true, + "esModuleInterop": false, "skipLibCheck": true, "allowJs": false, "allowSyntheticDefaultImports": true,