Skip to content

Conversation

@sigv
Copy link
Contributor

@sigv sigv commented Oct 3, 2016

The Archiver.bulk() call has been deprecated for a while and various answers on SO and other sites still suggest it, so if there are no planned maintenance fixes and updates to that function, everyone (even those who do not read the docs) should be informed that they are using something that is deprecated.

The Archiver.bulk() call has been deprecated for a while and various
answers on SO and other sites still suggest it, so if there are no
planned maintenance fixes and updates to that function, everyone (even
those who do not read the docs) should be informed that they are using
something that is deprecated.
lib/core.js Outdated
* @return {this}
*/
Archiver.prototype.bulk = function(mappings) {
console.log('Archiver.bulk() deprecated since 0.21.0');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better do console.warn (or console.error) it's safer to not pollute the stdout.

We also could leverage the new process.emitWarning? Only restriction is that it's node 6.0.0+ only.

Copy link
Contributor Author

@sigv sigv Oct 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The console.warn function is an alias for console.error according to docs, so no difference in those. I didn't know about the process.emitWarning so I will probably switch it over to that and figure out how to gracefully fall back to console.warn when run on older versions. There also appears to be a DeprecationWarning for the emitting which can be useful.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I know for the alias that's why I specified (or console.error).

+1 about the fall back, you can just test process && process.emitWarning !== undefined (where process is in case it's beeing used in the navigator)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed 98fa973 to prefer process.emitWarning over console.warn.

The process.emitWarning call is much fancier than the plain logging
call as the user can --throw-deprecation or --no-deprecation if he
or she prefers to. As a fallback, we just console.warn to stderr.
@sigv sigv changed the title Add a console.log call for @deprecated Add a process.emitWarning for the deprecated function Oct 3, 2016
@sigv sigv changed the title Add a process.emitWarning for the deprecated function Add a process.emitWarning for deprecated Oct 3, 2016
@sigv sigv changed the title Add a process.emitWarning for deprecated Add a process.emitWarning for deprecated Oct 3, 2016
lib/core.js Outdated
console.log('Archiver.bulk() deprecated since 0.21.0');
if (typeof process !== 'undefined' && typeof process.emitWarning !== 'undefined') {
process.emitWarning('Archiver.bulk() deprecated since 0.21.0', 'DeprecationWarning');
} else if (typeof console !== 'undefined' && typeof console.warn !== 'undefined') {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you think checking for availability of console.warn is overkill, let me know and I'll drop this check.

process.emitWarning('Archiver.bulk() deprecated since 0.21.0', 'DeprecationWarning');
} else if (typeof console !== 'undefined' && typeof console.warn !== 'undefined') {
console.warn('Archiver.bulk() deprecated since 0.21.0');
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 test of console is overkill, also you might want to declare a variable for the error string to avoid repeating it.

Then 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got ya.

The deprecation logging action should only take place once so that
the client does not get spammed with the warnings. Additionally, the
console is now always expected to be around.
process.emitWarning('Archiver.bulk() deprecated since 0.21.0', 'DeprecationWarning');
} else {
console.warn('Archiver.bulk() deprecated since 0.21.0');
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sorry there's been a misunderstanding,

I was thinking into something like:

var warning = 'Archiver.bulk() deprecated since 0.21.0'
if (typeof process !== 'undefined' && typeof process.emitWarning !== 'undefined') {
    process.emitWarning(warning, 'DeprecationWarning');
} else {
    console.warn(warning);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, that can be done as well. Do you want me to leave the _loggedBulkDeprecation in there or do you want me to log on each call?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed 86b1123 which deals with the repeated string. If you want me to drop the _loggedBulkDeprecation, let me know.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a nice improvement imo, let's see what @ctalkington thinks

Code maintainability and clean'ness and such features are included
in this commit.
@sigv
Copy link
Contributor Author

sigv commented Oct 6, 2016

How long does it usually take for @ctalkington to look into proposed changes?

@soyuka
Copy link
Contributor

soyuka commented Oct 6, 2016

He is really busy but no worries it'll eventually get merged ;)

@ctalkington
Copy link
Member

@sigv thanks for your contribution and thanks @soyuka for reviewing this. ill merge this and see about cutting a release this weekend.

@ctalkington ctalkington merged commit 0adf12c into archiverjs:master Oct 6, 2016
@sigv
Copy link
Contributor Author

sigv commented Oct 6, 2016

I expected something like having this merged next week or so if you were so busy.
Appreciate all the work! Thank you!

@sigv sigv deleted the deprecate-bulk branch October 6, 2016 15:04
@ctalkington
Copy link
Member

@sigv sorry this took so long to publish, i try to do things in bundles but I went ahead and cut a 1.2.0 release that includes this.

@SimenB
Copy link
Contributor

SimenB commented Dec 8, 2016

I appreciate a deprecation warning as much as the next guy, but this is a bit too much...

image

@sigv
Copy link
Contributor Author

sigv commented Dec 11, 2016

When you create the Archiver object, the _loggedBulkDeprecation flag is set to false. Simple as that.

@soyuka You want me to set it on the Archiver directly instead of the created object?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants