Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: commonjs clients crash #139

Merged
merged 1 commit into from
May 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

import path from "node:path";
import {EOL} from "os";
import { availableProviders, match } from './provider.js'
Expand Down Expand Up @@ -37,11 +38,17 @@ function logOptionsAndEnvironmentsVariables(alongsideText,valueToBePrinted) {
* @private
*/
function selectExhortBackend(opts= {}) {

let dirName
// new ESM way in nodeJS ( since node version 22 ) to bring module directory.
let dirName = import.meta.dirname
// old ESM way in nodeJS ( before node versions 22.00 to bring module directory.
dirName = import.meta.dirname
// old ESM way in nodeJS ( before node versions 22.00 to bring module directory)
if (!dirName) {
dirName = url.fileURLToPath(new URL('.', import.meta.url));
dirName = url.fileURLToPath(new URL('.', import.meta.url));
}

if (!dirName && __dirname !== undefined && __dirname !== null) {
dirName = __dirname;
}
let packageJson = JSON.parse(fs.readFileSync(path.join(dirName, "..","package.json" )).toString())
logOptionsAndEnvironmentsVariables("exhort-javascript-api analysis started, version: ",packageJson.version)
Expand Down
Loading