-
-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Do not set displayName. #91
Conversation
Unfortunate the way coveralls considers coverage to have dropped by percentage only. This patch deletes one line that was previously covered, so 204/205 lines covered is less than the previous 205/206 lines covered. |
Wow, I need to make that threshold more forgiving 😂 |
@coreyfarrell I have this little voice in the back of my head that says we added the task wrapper for a specific reason related to the gulp-cli. I can't quite remember what that was and have been trying to do some code spelunking to find it. Maybe @sttk or @erikkemperman remembers why we did it. |
@coreyfarrell so I've been trying to do some code-spelunking to figure this out. Currently all tests pass (here and in gulp-cli) when I pull in your changes. I think we might not be testing all the edge cases. @sttk do you know what these changes would effect? |
Sorry, I meant to reply here but didn’t get around to it... If I remember correctly the displayName is only populated in undertaker so it has a default, to be overridden if the user wants. But if I understand the issue properly, the former actually breaks the latter in the new style of exporting tasks. I think the proposed change is probably all right; the only edge case I can think of is the exported tree as used by external tooling (e.g. JetBrains had something I believe) might get out of whack and not reflect the latest displayName if it’s set post-export? But then I’m not sure if those tools are dealing with the exports correctly at the moment, I haven’t used them myself in a while. Would it be possible to make the function passed to the task “constructor” use a setter for displayName so that we can update the tree? Apologies if this doesn’t make sense, it’s been a while since I’ve thought about this stuff. |
I have not checked this yet. Please give me some time to check. |
I've checked this. For gulp-cli, this PR effects nothing because gulp-cli receives task names from Undertaker#tree (for Only one thing which concerns me is about the result of import gulp from 'gulp';
function testLocal() { return Promise.resolve(); }
console.log(gulp.task("testLocal").name); // => "taskWrapper" (current & this PR)
console.log(gulp.task("testLocal").displayName); // => "testLocal" (current) ==> undefined (this PR)
console.log(gulp.task("testLocal").unwrap().name); // => "testLocal" (current & this PR)
console.log(gulp.task("testLocal").unwrap().displayName); => // undefined (current & this PR) import gulp from 'gulp';
function testLocal() { return Promise.resolve(); }
testLocal.displayName = 'test-local';
gulp.task(testLocal)
console.log(gulp.task("test-local").name); // => "taskWrapper" (current & this PR)
console.log(gulp.task("test-local").displayName); // => "test-local" (current) ==> undefined (this PR)
console.log(gulp.task("test-local").unwrap().name); // => "testLocal" (current & this PR)
console.log(gulp.task("test-local").unwrap().displayName); // => "test-local" (current & this PR) import gulp from 'gulp';
function testLocal() { return Promise.resolve(); }
testLocal.displayName = 'test-local';
gulp.task("test", testLocal)
console.log(gulp.task("test").name); // => "taskWrapper" (current & this PR)
console.log(gulp.task("test").displayName); // => "test" (current) ==> undefined (this PR)
console.log(gulp.task("test").unwrap().name); // => "testLocal" (current & this PR)
console.log(gulp.task("test").unwrap().displayName); // => "test-local" (current & this PR) |
I've removed the change from |
I think I might remember why we were creating (edit): the above shouldn't affect series and parallel because they generate their own function wrappers, I think. Still need to do some digging. |
@coreyfarrell I remembered why I had added the displayName to functions generated by these 2 methods: Because I happened to remember this because I wanted to write a test like: taker.task(taker.series(fn1, fn2)); I was expecting this to throw because we removed the displayName but they can still be registered because those function names are being set. I think I'm going to remove the named functions inside bach (at a later date) and make it so you can't directly register the results of a series/parallel call. I think ensuring they are always named by users is a better default. |
@coreyfarrell I've merged this but it's late so I'll publish it tomorrow or Sunday. |
@coreyfarrell published as 1.2.1 - feel free to work on the needed PR inside gulp-cli |
And thanks for digging into this! |
Posted to gulpjs/gulp-cli#189. |
This will allow
gulp-cli
to preferentially use displayName tocalculate the name of the task. Previously when displayName was set in
series and parallel this caused tasks declared with exports to have the
wrong name. I've removed setting of displayName from set-task.js for
consistency, this is not required for the fix.