Skip to content

Commit

Permalink
fix: esm compatibility with require.main (resolves #49)
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed May 17, 2021
1 parent be5c914 commit 5d8024f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ function getEnv (): Context['environment'] {
}

function getCLI () {
const entry = require.main.filename
let entry
if (typeof require !== 'undefined' && require.main && require.main.filename) {
entry = require.main.filename
} else {
entry = process.argv[1]
}

const knownCLIs = {
'nuxt-ts.js': 'nuxt-ts',
Expand Down

0 comments on commit 5d8024f

Please sign in to comment.