🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

gulp-useref

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-useref - npm Package Compare versions

Comparing version
4.0.0
to
4.0.1
+60
-66
index.js

@@ -1,18 +0,17 @@

'use strict';
var path = require('path'),
PluginError = require('plugin-error'),
es = require('event-stream'),
through = require('through2'),
useref = require('useref'),
getGlobs = require('./lib/getGlobs'),
addFilesFromExtStreams = require('./lib/addFilesFromExtStreams'),
addHtmlToStream = require('./lib/addHtmlToStream'),
unprocessedCounter = require('./lib/unprocessedCounter')(),
end = require('./lib/end')(),
additionalFiles = [],
transforms,
pluginOptions;
const path = require('path');
const PluginError = require('plugin-error');
const es = require('event-stream');
const through = require('through2');
const useref = require('useref');
const getGlobs = require('./lib/getGlobs');
const addFilesFromExtStreams = require('./lib/addFilesFromExtStreams');
const addHtmlToStream = require('./lib/addHtmlToStream');
const unprocessedCounter = require('./lib/unprocessedCounter')();
const end = require('./lib/end')();
const additionalFiles = [];
let transforms;
let pluginOptions;
function handleAdditionalStreams(additionalStreams) {
var _additionalStreams = additionalStreams;
let _additionalStreams = additionalStreams;

@@ -23,24 +22,22 @@ if (!Array.isArray(additionalStreams)) {

return _additionalStreams.map(function (stream) {
// filters stream to select needed files
return stream.pipe(es.through(function (file) {
additionalFiles.push(file);
}));
});
// filters stream to select needed files
return _additionalStreams.map(stream => stream.pipe(es.through(file => {
additionalFiles.push(file);
})));
}
function addAssetsToStream(paths, files) {
var self = this,
gulpif = require('gulp-if'),
concat = require('gulp-concat'),
vfs = require('vinyl-fs'),
extend = require('extend'),
src,
globs,
name = paths.name,
basePath = paths.basePath,
filepaths = files[name].assets,
type = paths.type,
options = extend({}, pluginOptions),
gulpConcatOptions = {};
const self = this;
const gulpif = require('gulp-if');
const concat = require('gulp-concat');
const vfs = require('vinyl-fs');
const extend = require('extend');
let src;
let globs;
const name = paths.name;
const basePath = paths.basePath;
const filepaths = files[name].assets;
const type = paths.type;
const options = extend({}, pluginOptions);
const gulpConcatOptions = {};

@@ -55,7 +52,4 @@ if (!filepaths.length) {

globs = filepaths
.filter(function (url) {
// test if url is relative
return !/^(?:\w+:)?\/\//.test(url);
})
.map(function (filepath) {
.filter(url => !/^(?:\w+:)?\/\//.test(url)) // test if url is relative
.map(filepath => {
paths.filepath = filepath;

@@ -70,3 +64,3 @@

})
.on('error', function (err) {
.on('error', err => {
self.emit('error', new Error(err));

@@ -79,3 +73,3 @@ });

// If any external transforms were included, pipe all files to them first
transforms.forEach(function (fn) {
transforms.forEach(fn => {
src = src.pipe(fn(name));

@@ -96,3 +90,3 @@ });

.pipe(gulpif(!options.noconcat, concat(name, gulpConcatOptions)))
.pipe(through.obj(function (newFile, encoding, callback) {
.pipe(through.obj((newFile, encoding, callback) => {
// specify an output path relative to the cwd

@@ -108,4 +102,4 @@ if (options.base) {

}))
.on('finish', function () {
var unprocessed = unprocessedCounter.decrement();
.on('finish', () => {
const unprocessed = unprocessedCounter.decrement();

@@ -119,9 +113,9 @@ if (unprocessed === 0 && end.get()) {

function processAssets(file, basePath, data) {
var self = this,
types = pluginOptions.types || [ 'css', 'js' ];
function processAssets({ cwd }, basePath, data) {
const self = this;
const types = pluginOptions.types || [ 'css', 'js' ];
types.forEach(function (type) {
var files = data[type],
name;
types.forEach(type => {
const files = data[type];
let name;

@@ -134,8 +128,8 @@ if (!files) {

addAssetsToStream.call(self, {
name: name,
basePath: basePath,
name,
basePath,
searchPath: pluginOptions.searchPath,
cwd: file.cwd,
cwd,
transformPath: pluginOptions.transformPath,
type: type
type
}, files);

@@ -147,5 +141,5 @@ }

module.exports = function (options) {
var opts = options || {},
waitForAssets,
additionalStreams;
const opts = options || {};
let waitForAssets;
let additionalStreams;

@@ -167,10 +161,10 @@ pluginOptions = opts;

return through.obj(function (file, enc, cb) {
var self = this;
const self = this;
waitForAssets.pipe(es.wait(function () {
var output,
waitForAssets.pipe(es.wait(() => {
let output;
// Cache the file base path relative to the cwd
// Use later when it could be dropped
_basePath = path.dirname(file.path);
// Cache the file base path relative to the cwd
// Use later when it could be dropped
const _basePath = path.dirname(file.path);

@@ -201,5 +195,5 @@ if (file.isNull()) {

}
}, function (cb) {
var unprocessed = unprocessedCounter.get(),
fn = function () {};
}, cb => {
const unprocessed = unprocessedCounter.get();
let fn = () => {};

@@ -206,0 +200,0 @@ end.set(cb);

@@ -1,10 +0,8 @@

'use strict';
const reorderTheStream = require('./reorderTheStream');
var reorderTheStream = require('./reorderTheStream');
module.exports = function (additionalFiles, globs, src) {
var self = this,
source;
const self = this;
let source;
additionalFiles.forEach(function (addFile) {
additionalFiles.forEach(addFile => {
src.push(addFile);

@@ -11,0 +9,0 @@ });

@@ -1,7 +0,5 @@

'use strict';
const PluginError = require('plugin-error');
var PluginError = require('plugin-error');
module.exports = function (file, data) {
var self = this;
const self = this;

@@ -8,0 +6,0 @@ try {

@@ -1,6 +0,4 @@

'use strict';
module.exports = () => {
let _end;
module.exports = function () {
var _end;
function get() {

@@ -21,6 +19,6 @@ return _end;

return {
get: get,
set: set,
fn: fn
get,
set,
fn
};
};

@@ -1,18 +0,16 @@

'use strict';
const getPattern = require('./getPattern');
var getPattern = require('./getPattern');
module.exports = (paths, files) => {
let pattern;
let matches;
const glob = require('glob');
let searchPath = paths.searchPath;
const name = paths.name;
const cwd = paths.cwd;
const basePath = paths.basePath;
const filepath = paths.filepath;
const transformPath = paths.transformPath;
module.exports = function (paths, files) {
var pattern,
matches,
glob = require('glob'),
searchPath = paths.searchPath,
name = paths.name,
cwd = paths.cwd,
basePath = paths.basePath,
filepath = paths.filepath,
transformPath = paths.transformPath;
if (searchPath && Array.isArray(searchPath)) {
searchPath = searchPath.length === 1 ? searchPath[0] : '{' + searchPath.join(',') + '}';
searchPath = searchPath.length === 1 ? searchPath[0] : `{${searchPath.join(',')}}`;
}

@@ -22,5 +20,5 @@

destPath: name,
searchPath: searchPath,
cwd: cwd,
basePath: basePath,
searchPath,
cwd,
basePath,
srcPath: filepath

@@ -27,0 +25,0 @@ });

@@ -1,13 +0,11 @@

'use strict';
const path = require('path');
var path = require('path');
module.exports = (files, paths) => {
let searchPaths;
const destPath = paths.destPath;
const searchPath = paths.searchPath;
const cwd = paths.cwd;
const basePath = paths.basePath;
const srcPath = paths.srcPath;
module.exports = function (files, paths) {
var searchPaths,
destPath = paths.destPath,
searchPath = paths.searchPath,
cwd = paths.cwd,
basePath = paths.basePath,
srcPath = paths.srcPath;
if (files[destPath].searchPaths || searchPath) {

@@ -14,0 +12,0 @@ searchPaths = path.resolve(cwd, files[destPath].searchPaths || searchPath);

@@ -1,19 +0,17 @@

'use strict';
const through = require('through2');
var through = require('through2');
module.exports = function (globs, src) {
var self = this,
sortIndex = {},
i = 0,
sortedFiles = [],
unsortedFiles = [];
const self = this;
const sortIndex = {};
let i = 0;
const sortedFiles = [];
const unsortedFiles = [];
// Create a sort index so we don't iterate over the globs for every file
globs.forEach(function (filename) {
globs.forEach(filename => {
sortIndex[filename] = i++;
});
return src.pipe(through.obj(function (srcFile, encoding, callback) {
var index = sortIndex[srcFile.path];
return src.pipe(through.obj((srcFile, encoding, callback) => {
const index = sortIndex[srcFile.path];

@@ -26,3 +24,3 @@ if (index === undefined) {

callback();
}, function (callback) {
}, callback => {
sortedFiles.forEach(function (sorted) {

@@ -29,0 +27,0 @@ if (sorted !== undefined) {

@@ -1,16 +0,14 @@

'use strict';
module.exports = () => {
let unprocessed = 0;
module.exports = function () {
var unprocessed = 0;
return {
get: function () {
get() {
return unprocessed;
},
increment: function () {
increment() {
return unprocessed++;
},
decrement: function () {
decrement() {
return --unprocessed;

@@ -17,0 +15,0 @@ }

{
"name": "gulp-useref",
"version": "4.0.0",
"version": "4.0.1",
"description": "Parse build blocks in HTML files to replace references to non-optimized scripts or stylesheets.",

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

"extend": "^3.0.2",
"glob": "^7.1.4",
"glob": "^7.1.6",
"gulp-concat": "^2.6.1",

@@ -18,3 +18,3 @@ "gulp-if": "^3.0.0",

"through2": "^3.0.1",
"useref": "^1.4.2",
"useref": "^1.4.3",
"vinyl-fs": "^3.0.3"

@@ -24,10 +24,11 @@ },

"async-once": "^1.0.1",
"coveralls": "^3.0.6",
"babel-eslint": "^10.0.3",
"coveralls": "^3.0.9",
"gulp": "^4.0.2",
"gulp-eslint": "^6.0.0",
"gulp-mocha": "^7.0.2",
"gulp-rename": "^1.4.0",
"gulp-rename": "^2.0.0",
"mocha": "*",
"mock-gulp-dest": "^0.1.1",
"nyc": "^14.1.1",
"nyc": "^15.0.0",
"should": "*",

@@ -34,0 +35,0 @@ "vinyl": "^2.2.0"