Skip to content

Commit

Permalink
Replace dirname functionality for ESM (fix)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukiffer committed Apr 10, 2024
1 parent 34bd4d7 commit d1df8c9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/writer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { readFile } from 'fs/promises';
import { resolve } from 'path';
import { fileURLToPath } from 'url'

const dirname = fileURLToPath(new URL('.', import.meta.url));

function getCommitGroup(type) {
switch (type) {
Expand Down Expand Up @@ -56,8 +59,8 @@ function getWriterOpts() {

export async function createWriterOpts() {
const writerOpts = getWriterOpts();
writerOpts.mainTemplate = await readFile(resolve(__dirname, './templates/template.hbs'), 'utf-8');
writerOpts.headerPartial = await readFile(resolve(__dirname, './templates/header.hbs'), 'utf-8');
writerOpts.commitPartial = await readFile(resolve(__dirname, './templates/commit.hbs'), 'utf-8');
writerOpts.mainTemplate = await readFile(resolve(dirname, './templates/template.hbs'), 'utf-8');
writerOpts.headerPartial = await readFile(resolve(dirname, './templates/header.hbs'), 'utf-8');
writerOpts.commitPartial = await readFile(resolve(dirname, './templates/commit.hbs'), 'utf-8');
return writerOpts;
}

0 comments on commit d1df8c9

Please sign in to comment.