Skip to content

Commit

Permalink
Add error catching for older node versions without process.emitWarning
Browse files Browse the repository at this point in the history
  • Loading branch information
itotallyrock committed Jun 5, 2017
1 parent 08e3d45 commit f8bda5c
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,14 @@ function SpotifyWebHelper(opts) {
this.player.emit('track-will-change', status.track);
let hadListeners = this.player.emit('track-change', status.track);
if (hadListeners) {
process.emitWarning(
'\'track-change\' was renamed to \'track-will-change\', please update your listener',
'DeprecationWarning'
);
if (process.emitWarning) {
process.emitWarning(
'\'track-change\' was renamed to \'track-will-change\', please update your listener',
'DeprecationWarning'
);
} else {
console.warn('DeprecationWarning: \'track-change\' was renamed to \'track-will-change\', please update your listener')
}
}
}
if (this.status.playing !== status.playing) {
Expand Down Expand Up @@ -298,10 +302,14 @@ function SpotifyWebHelper(opts) {
this.player.emit('track-will-change', res.track);
let hadListeners = this.player.emit('track-change', this.status.track);
if (hadListeners) {
process.emitWarning(
'\'track-change\' was renamed to \'track-will-change\', please update your listener',
'DeprecationWarning'
);
if (process.emitWarning) {
process.emitWarning(
'\'track-change\' was renamed to \'track-will-change\', please update your listener',
'DeprecationWarning'
);
} else {
console.warn('DeprecationWarning: \'track-change\' was renamed to \'track-will-change\', please update your listener')
}
}
}
resolve();
Expand Down

0 comments on commit f8bda5c

Please sign in to comment.