Skip to content

Commit

Permalink
fix: commonjs clients crash
Browse files Browse the repository at this point in the history
Signed-off-by: Zvi Grinberg <[email protected]>
  • Loading branch information
zvigrinberg committed May 16, 2024
1 parent 6e404dc commit 0d67bdf
Showing 1 changed file with 10 additions and 3 deletions.
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

0 comments on commit 0d67bdf

Please sign in to comment.