Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-rev-all

Package Overview
Dependencies
Maintainers
1
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-rev-all - npm Package Compare versions

Comparing version 0.8.22 to 0.8.23

4

gulpfile.js

@@ -10,3 +10,3 @@ /* jshint node:true */

gulp.task('lint', function() {
return gulp.src('test/test.js')
return gulp.src('test.js')
.pipe(jshint())

@@ -17,2 +17,2 @@ .pipe(jshint.reporter('default'))

gulp.task('default', ['lint']);
gulp.task('default', ['lint']);

@@ -7,2 +7,6 @@ var Through = require('through2');

var RevAll = function (options) {
if (!(this instanceof RevAll)) {
return new RevAll(options);
}

@@ -9,0 +13,0 @@ this.revisioner = new Revisioner(options);

{
"name": "gulp-rev-all",
"version": "0.8.22",
"version": "0.8.23",
"description": "Static asset revisioning by appending content hash to filenames: unicorn.css => unicorn.098f6bcd.css, also re-writes references in each file to new reved name.",

@@ -15,3 +15,3 @@ "main": "index.js",

"gulp-jshint": "~1.5.1",
"gulp-mocha": "~0.4.1",
"gulp-mocha": "~2.2.0",
"mocha": "~2.2.1",

@@ -18,0 +18,0 @@ "should": "*"

@@ -202,2 +202,8 @@ var Gutil = require('gulp-util');

fileResolveReferencesIn.revReferenceFiles = {};
var referenceGroupRelative = [];
var referenceGroupAbsolute = [];
fileResolveReferencesIn.referenceGroupsContainer = {
'relative': referenceGroupRelative,
'absolute': referenceGroupAbsolute
};

@@ -209,9 +215,2 @@ // Don't try and resolve references in binary files or files that have been blacklisted

var referenceGroupRelative = [];
var referenceGroupAbsolute = [];
var referenceGroupsContainer = {
'relative': referenceGroupRelative,
'absolute': referenceGroupAbsolute
};
// For the current file (fileResolveReferencesIn), look for references to any other file in the project

@@ -243,4 +242,4 @@ for (var path in this.files) {

// Priority relative references higher than absolute
for (var referenceType in referenceGroupsContainer) {
var referenceGroup = referenceGroupsContainer[referenceType];
for (var referenceType in fileResolveReferencesIn.referenceGroupsContainer) {
var referenceGroup = fileResolveReferencesIn.referenceGroupsContainer[referenceType];

@@ -267,3 +266,3 @@ for (var referenceIndex = 0, referenceGroupLength = referenceGroup.length; referenceIndex < referenceGroupLength; referenceIndex++) {

} else {
this.log('gulp-rev-all:', 'Possible ambiguous refrence detected [', Gutil.colors.red(fileResolveReferencesIn.revReferencePaths[reference.path].path), ' (', fileResolveReferencesIn.revReferencePaths[reference.path].file.revPathOriginal, ')] <-> [', Gutil.colors.red(reference.path), '(', Gutil.colors.red(reference.file.revPathOriginal), ')]');
this.log('gulp-rev-all:', 'Possible ambiguous reference detected [', Gutil.colors.red(fileResolveReferencesIn.revReferencePaths[reference.path].path), ' (', fileResolveReferencesIn.revReferencePaths[reference.path].file.revPathOriginal, ')] <-> [', Gutil.colors.red(reference.path), '(', Gutil.colors.red(reference.file.revPathOriginal), ')]');
}

@@ -301,2 +300,8 @@ }

// This file's hash should change if any of its references will be prefixed.
if (this.options.prefix &&
Object.keys(file.referenceGroupsContainer.absolute).length) {
hash += this.options.prefix;
}
// Consolidate many hashes into one

@@ -369,3 +374,3 @@ hash = this.Tool.md5(hash);

if (this.options.transformPath) {

@@ -442,2 +447,7 @@ // Transform path using client supplied transformPath callback,

}
if (!this.shouldFileBeRenamed(file)) {
return false;
}
return true;

@@ -444,0 +454,0 @@

@@ -69,2 +69,25 @@ var RevAll = require('./index');

it('should change if the prefix changed and it has absolute references', function (done) {
setup();
streamRevision.on('data', function (file) { });
streamRevision.on('end', function () {
var pathBaseline = files['/index.html'].path;
// Apply a prefix to absolute references.
revisioner.options.prefix = 'http://example.com/';
// Re-run the revisioner to re-calculate the filename hash
revisioner.run();
files['/index.html'].path.should.not.equal(pathBaseline);
done();
});
gulp.src(['test/fixtures/config1/**']).pipe(streamRevision);
});
/**

@@ -110,3 +133,3 @@ * Should resolve hash change, both ways

files['/view/main.html'].path.should.equal(pathMainBaseline);
// Try the other reference

@@ -1245,2 +1268,26 @@ files['/view/main.html'].revHashOriginal = 'changed';

it('1 deep to similar directory', function () {
var base = '/first/second';
var file = new Gutil.File({
path: '/first/second/third/index.html',
base: base
});
var fileReference = new Gutil.File({
path: '/first/second/thirder/index.html',
base: base
});
file.revPathOriginal = file.path;
fileReference.revPathOriginal = fileReference.path;
var references = Tool.get_reference_representations_relative(fileReference, file);
references.length.should.equal(1);
references[0].should.equal('../thirder/index.html');
});
it('2 deep', function () {

@@ -1512,2 +1559,27 @@

it('1 deep to similar directory', function () {
var base = '/first/second';
var file = new Gutil.File({
path: '/first/second/thirder/index.html',
base: base
});
var fileReference = new Gutil.File({
path: '/first/second/third/index.html',
base: base
});
file.revPathOriginal = file.path;
fileReference.revPathOriginal = fileReference.path;
var references = Tool.get_reference_representations_absolute(fileReference, file);
references.length.should.equal(2);
references[0].should.equal('/third/index.html');
references[1].should.equal('third/index.html');
});
it('2 deep', function () {

@@ -1514,0 +1586,0 @@

@@ -11,2 +11,6 @@ var Path = require('path');

};
var dirname_with_sep = function(path) {
return Path.dirname(path) + '/';
}

@@ -40,4 +44,4 @@ var join_path_url = function (prefix, path) {

// Sanitize inputs, convert windows to posix style slashes, remove trailing slash off base is there is one
base = base.replace(/^[a-z]:/i, '').replace(/\\/g, '/').replace(/\/$/g, '');
// Sanitize inputs, convert windows to posix style slashes, ensure trailing slash for base
base = base.replace(/^[a-z]:/i, '').replace(/\\/g, '/').replace(/\/$/g, '') + '/';
path = path.replace(/^[a-z]:/i, '').replace(/\\/g, '/');

@@ -47,3 +51,3 @@

if (base === path.substr(0, base.length)) {
path = path.substr(base.length);
path = '/' + path.substr(base.length);
}

@@ -99,3 +103,3 @@

if (Path.dirname(fileCurrentReference.path).indexOf(Path.dirname(file.path)) === 0) {
if (dirname_with_sep(fileCurrentReference.path).indexOf(dirname_with_sep(file.path)) === 0) {

@@ -116,7 +120,7 @@ // index.html

if (Path.dirname(file.path) !== Path.dirname(fileCurrentReference.path) &&
Path.dirname(fileCurrentReference.path).indexOf(Path.dirname(file.path)) === -1) {
if (dirname_with_sep(file.path) !== dirname_with_sep(fileCurrentReference.path) &&
dirname_with_sep(fileCurrentReference.path).indexOf(dirname_with_sep(file.path)) === -1) {
var pathCurrentReference = Path.dirname(get_relative_path(fileCurrentReference.base, fileCurrentReference.revPathOriginal));
var pathFile = Path.dirname(get_relative_path(file.base, file.revPathOriginal));
var pathCurrentReference = dirname_with_sep(get_relative_path(fileCurrentReference.base, fileCurrentReference.revPathOriginal));
var pathFile = dirname_with_sep(get_relative_path(file.base, file.revPathOriginal));

@@ -123,0 +127,0 @@ // ../second/index.html

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc