Skip to content

Commit

Permalink
Silence potentially upcoming circular dependency warning
Browse files Browse the repository at this point in the history
Node.js is currently considering printing a warning when a non-existent
property of `module.exports` is accessed while in a circular `require()`
dependency, in order to make it easier to catch issues with circular
dependencies.

In order to avoid printing these warnings for shelljs, checking for the
property’s existence rather than its truthiness suffices.

Refs: nodejs/node#29935
  • Loading branch information
addaleax committed Oct 18, 2019
1 parent 9aef002 commit a6bb08e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/common.js
Expand Up @@ -478,7 +478,7 @@ function _register(name, implementation, wrapOptions) {
// If an option isn't specified, use the default
wrapOptions = Object.assign({}, DEFAULT_WRAP_OPTIONS, wrapOptions);

if (shell[name]) {
if (shell.hasOwnProperty(name)) {
throw new Error('Command `' + name + '` already exists');
}

Expand Down

0 comments on commit a6bb08e

Please sign in to comment.