Skip to content

Commit

Permalink
fix: add debug warning if native extension couldn't be loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
flotwig committed Mar 12, 2019
1 parent 53ba079 commit 670ed39
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/index.js
@@ -1,5 +1,15 @@
const debug = require('debug')('get-windows-proxy')
const registry = require('@cypress/registry-js')
let registry

try {
registry = require('@cypress/registry-js')
} catch (err) {
if (err.code !== 'MODULE_NOT_FOUND') {
throw err
}

debug('Could not load native extension for Windows registry access. The most likely reason is that your Node version has changed since installing. Try re-installing get-windows-proxy.')
}

const findByName = (values, name) => {
return values.find((value) => {
Expand All @@ -8,6 +18,10 @@ const findByName = (values, name) => {
}

module.exports = function getWindowsProxy () {
if (!registry) {
return
}

debug('scanning Windows registry for proxy setting')

const values = registry.enumerateValues(
Expand Down

0 comments on commit 670ed39

Please sign in to comment.