Skip to content

Commit

Permalink
fix: don't fail if "fileURLToPath(import.meta.url)" throws
Browse files Browse the repository at this point in the history
Co-authored-by: Colin GILLE <colin.gille@blgcloud.com>
Co-authored-by: Benjamin E. Coe <bencoe@google.com>
  • Loading branch information
3 people committed Nov 26, 2021
1 parent 375b00b commit 3a44796
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/platform-shims/esm.mjs
Expand Up @@ -15,8 +15,13 @@ import y18n from 'y18n'
const REQUIRE_ERROR = 'require is not supported by ESM'
const REQUIRE_DIRECTORY_ERROR = 'loading a directory of commands is not supported yet for ESM'

const mainFilename = fileURLToPath(import.meta.url).split('node_modules')[0]
const __dirname = fileURLToPath(import.meta.url)
let __dirname;
try {
__dirname = fileURLToPath(import.meta.url);
} catch (e) {
__dirname = process.cwd();
}
const mainFilename = __dirname.split('node_modules')[0]

export default {
assert: {
Expand Down

0 comments on commit 3a44796

Please sign in to comment.