Skip to content

Commit

Permalink
Silence potentially upcoming circular dependency warning (#973)
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 authored and nfischer committed Apr 25, 2020
1 parent d4d1317 commit a1111ee
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,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 a1111ee

Please sign in to comment.