Skip to content

Commit

Permalink
Try to avoid querying Deno.permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
papandreou committed Nov 11, 2019
1 parent 4749590 commit 04c2ef7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/utils.js
Expand Up @@ -363,8 +363,15 @@ const utils = (module.exports = {
},

getEnv(varName) {
if (typeof Deno === 'object' && Deno.permissions().env) {
return Deno.env()[varName];
if (typeof Deno === 'object') {
try {
return Deno.env()[varName];
} catch (err) {
// Probably a permissions error because we don't have permission to read the environment variables
// Unfortunately the whole permissions API is async now:
// https://github.com/denoland/deno/pull/3200/files
// ... so we can't detect whether we do have access
}
} else if (typeof process === 'object' && process.env) {
return process.env[varName];
}
Expand Down

0 comments on commit 04c2ef7

Please sign in to comment.