Repository navigation
Add trailing separator to file.base if not present - #165
Conversation
|
@dmellstrom, I'm sorry to be slow to respond. Thank you for the PR. @tandrewnichols, could you please verify this fixes #153 for you as expected? |
|
Erm . . . probably not easily. I'm not currently working with anything using gulp. |
smurfyuen
left a comment
There was a problem hiding this comment.
@dmellstrom well done! I copied index.js into my local, the templateurl is back to relative path!
QA passed.
I am on the latest gulp too, which made there was and extra slash prefix.
|
@dmellstrom, thanks very much! 2.2.4 is released. Also, thanks for the review, @michaelcyyuen. I appreciate you two. |
| if (base === undefined) { | ||
| // Make sure file.base ends in a separator, to ensure correct relative | ||
| // path construction (provides compatibility with Gulp 4/Vinyl 2) | ||
| base = file.base += file.base.substr(-1) === path.sep ? "" : path.sep; |
There was a problem hiding this comment.
@simonua @dmellstrom this is a breaking change on my Gulp 3.9 configuration. My root is undefined and the file.base is an absolute folder path ending with backslash, so the line 68 sets base = "" and then the line 70 does not transform the absolute path file.path to a relative path.
There was a problem hiding this comment.
Can confirm this is an issue when running Gulp v3.9.1.
There was a problem hiding this comment.
@vanni-giachin & @davyjoe, bummer! My apologies for the breaking change. Given the still relatively high number of downloads of this package, I reverted and issued 2.2.5 to reestablish status quo prior to the breaking change.
@dmellstrom & @michaelcyyuen, I'm going to open the issues we closed with 2.2.4 again, so they can be tackled. I think the option for you is to lock into 2.2.4 (less desirable overall, really) or give it another go if you don't mind.
There was a problem hiding this comment.
@vanni-giachin @davyjoe I take it you are on Windows? (You mentioned a backslash.) Could you please give me more specific information about your configuration and the paths that are not working?
I haven't been able to replicate the regression you are describing on Windows/Gulp 3.9.1.
I can't see a possible value for file.base that would result in base = "".
There was a problem hiding this comment.
@dmellstrom I am running on a Mac. Here is a sample of how my gulp task is structured:
'use strict';
var templateCache = require('gulp-angular-templatecache');
var TEMPLATE_HEADER = '\'use strict\'; angular.module(\'<%= module %>\'<%= standalone %>).run([\'$templateCache\', function($templateCache) {';
var TEMPLATE_PATHS = [
'app/content/_doc1.html',
'app/components/myComponent1/*.html',
'app/components/myModal/_detail.html'
];
var TEMPLATE_MODULE = 'myModule';
var TEMPLATE_DESTINATION = 'app/scripts/templates';
gulp.task('templatecache', function () {
return gulp.src(TEMPLATE_PATHS)
.pipe(templateCache({ module: TEMPLATE_MODULE, templateHeader: TEMPLATE_HEADER }))
.pipe(gulp.dest(TEMPLATE_DESTINATION));
});
This PR is designed to make the plugin's ability to generate relative paths forwards-compatible with Gulp 4, without affecting current compatibility with Gulp 3. To do this, the system will make sure
file.baseincludes a trailing separator, addressing a change in vinyl.This affects test results, as they use vinyl directly. However, it doesn't affect the output of the package as used in Gulp 3.
Fixes #164, Fixes #153