Skip to content

Commit

Permalink
fix: for native ESM environments, pass in gitinfo to read to avoid …
Browse files Browse the repository at this point in the history
…erring
  • Loading branch information
brettz9 committed Jan 1, 2024
1 parent 548d82f commit 773c4ff
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/gitdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ const Parser = require('./parser');

/**
* @param {string} input Gitdown flavored markdown.
* @param {object} [gitInfo]
*/
Gitdown.read = (input) => {
Gitdown.read = (input, gitInfo) => {
let instanceConfig;
let instanceLogger;

Expand Down Expand Up @@ -218,7 +219,7 @@ Gitdown.read = (input) => {
findDeadFragmentIdentifiers: false,
findDeadURLs: false,
},
gitinfo: {
gitinfo: gitInfo || {
gitPath: gitdown.executionContext(),
},
headingNesting: {
Expand Down Expand Up @@ -248,15 +249,12 @@ Gitdown.readFile = (fileName) => {
encoding: 'utf8',
});

const gitdown = Gitdown.read(input);

const directoryName = path.dirname(fileName);

const gitdown = Gitdown.read(input, {
gitPath: directoryName
});
gitdown.setConfig({
baseDirectory: directoryName,
gitinfo: {
gitPath: directoryName,
},
baseDirectory: directoryName
});

return gitdown;
Expand Down

0 comments on commit 773c4ff

Please sign in to comment.