Skip to content

Add trailing separator to file.base if not present - #165

Merged
simonua merged 2 commits into
miickel:masterfrom
dmellstrom:relative-paths
Nov 6, 2018
Merged

simonua merged 2 commits into
miickel:masterfrom
dmellstrom:relative-paths

Conversation

@dmellstrom

Copy link
Copy Markdown
Contributor

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.base includes 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

@simonua

simonua commented Nov 2, 2018

Copy link
Copy Markdown
Collaborator

@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?

@simonua simonua self-assigned this Nov 2, 2018
@tandrewnichols

Copy link
Copy Markdown
Contributor

Erm . . . probably not easily. I'm not currently working with anything using gulp.

@smurfyuen smurfyuen left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@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.

Comment thread index.js Resolved
@simonua
simonua merged commit 4149664 into miickel:master Nov 6, 2018
@simonua

simonua commented Nov 6, 2018

Copy link
Copy Markdown
Collaborator

@dmellstrom, thanks very much! 2.2.4 is released. Also, thanks for the review, @michaelcyyuen. I appreciate you two.

Comment thread index.js
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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@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.

@davyjoe davyjoe Nov 7, 2018 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can confirm this is an issue when running Gulp v3.9.1.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@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 = "".

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@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));
});

simonua pushed a commit that referenced this pull request Nov 7, 2018
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.

6 participants