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

gulp-newer

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-newer - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

60

index.js

@@ -8,6 +8,4 @@ var Transform = require('stream').Transform;

var Q = require('kew');
var gutil = require('gulp-util');
var PluginError = require('plugin-error');
var PluginError = gutil.PluginError;
var PLUGIN_NAME = 'gulp-newer';

@@ -19,4 +17,6 @@

if (!options) {
throw new PluginError(PLUGIN_NAME,
'Requires a dest string or options object');
throw new PluginError(
PLUGIN_NAME,
'Requires a dest string or options object'
);
}

@@ -39,3 +39,6 @@

if (!options.dest && !options.map) {
throw new PluginError(PLUGIN_NAME, 'Requires either options.dest or options.map or both');
throw new PluginError(
PLUGIN_NAME,
'Requires either options.dest or options.map or both'
);
}

@@ -47,3 +50,6 @@

} else if (!Array.isArray(options.extra)) {
throw new PluginError(PLUGIN_NAME, 'Requires options.extra to be a string or array');
throw new PluginError(
PLUGIN_NAME,
'Requires options.extra to be a string or array'
);
}

@@ -74,3 +80,5 @@ }

*/
this._destStats = this._dest ? Q.nfcall(fs.stat, this._dest) : Q.resolve(null);
this._destStats = this._dest
? Q.nfcall(fs.stat, this._dest)
: Q.resolve(null);

@@ -133,13 +141,17 @@ /**

if (error && error.path) {
throw new PluginError(PLUGIN_NAME, 'Failed to read stats for an extra file: ' + error.path);
throw new PluginError(
PLUGIN_NAME,
'Failed to read stats for an extra file: ' + error.path
);
} else {
throw new PluginError(PLUGIN_NAME, 'Failed to stat extra files; unknown error: ' + error);
throw new PluginError(
PLUGIN_NAME,
'Failed to stat extra files; unknown error: ' + error
);
}
});
}
}
util.inherits(Newer, Transform);
/**

@@ -163,10 +175,11 @@ * Pass through newer files only.

var ext = path.extname(relative);
var destFileRelative = self._ext ?
relative.substr(0, relative.length - ext.length) + self._ext :
relative;
var destFileRelative = self._ext
? relative.substr(0, relative.length - ext.length) + self._ext
: relative;
if (self._map) {
destFileRelative = self._map(destFileRelative);
}
var destFileJoined = self._dest ?
path.join(self._dest, destFileRelative) : destFileRelative;
var destFileJoined = self._dest
? path.join(self._dest, destFileRelative)
: destFileRelative;
return Q.all([Q.nfcall(fs.stat, destFileJoined), extraStats]);

@@ -180,3 +193,4 @@ } else {

}
}).fail(function(err) {
})
.fail(function(err) {
if (err.code === 'ENOENT') {

@@ -189,3 +203,4 @@ // dest file or directory doesn't exist, pass through all

}
}).spread(function(destFileStats, extraFileStats) {
})
.spread(function(destFileStats, extraFileStats) {
var newer = !destFileStats || srcFile.stat.mtime > destFileStats.mtime;

@@ -216,7 +231,7 @@ // If *any* extra file is newer than a destination file, then ALL

done();
}).fail(done).end();
})
.fail(done)
.end();
};
/**

@@ -231,3 +246,2 @@ * Remove references to buffered files.

/**

@@ -234,0 +248,0 @@ * Only pass through source files that are newer than the provided destination.

{
"name": "gulp-newer",
"version": "1.3.0",
"version": "1.4.0",
"description": "Only pass through newer source files",

@@ -26,17 +26,19 @@ "homepage": "https://github.com/tschaub/gulp-newer",

"scripts": {
"pretest": "eslint index.js spec.js",
"lint": "eslint index.js spec.js",
"pretest": "npm run lint",
"test": "mocha spec.js"
},
"devDependencies": {
"chai": "^3.5.0",
"eslint": "^3.7.1",
"eslint-config-tschaub": "^6.0.0",
"chai": "^4.1.2",
"eslint": "^4.14.0",
"eslint-config-tschaub": "^9.0.0",
"gulp": "^3.9.1",
"mocha": "^3.1.0",
"mock-fs": "^3.11.0"
"mocha": "^4.1.0",
"mock-fs": "^4.4.2",
"vinyl": "^2.1.0"
},
"dependencies": {
"glob": "^7.0.3",
"gulp-util": "^3.0.7",
"kew": "^0.7.0"
"kew": "^0.7.0",
"plugin-error": "^0.1.2"
},

@@ -43,0 +45,0 @@ "eslintConfig": {

@@ -8,3 +8,3 @@ /* eslint-env mocha */

var chai = require('chai');
var gutil = require('gulp-util');
var Vinyl = require('vinyl');
var mock = require('mock-fs');

@@ -16,3 +16,2 @@

var File = gutil.File;
var assert = chai.assert;

@@ -28,7 +27,9 @@

paths.forEach(function(filePath) {
stream.write(new File({
contents: fs.readFileSync(filePath),
path: path.resolve(filePath),
stat: fs.statSync(filePath)
}));
stream.write(
new Vinyl({
contents: fs.readFileSync(filePath),
path: path.resolve(filePath),
stat: fs.statSync(filePath)
})
);
});

@@ -39,3 +40,2 @@ stream.end();

describe('newer()', function() {
it('creates a transform stream', function() {

@@ -47,3 +47,2 @@ var stream = newer('foo');

it('requires a string dest or an object with the dest property', function() {
assert.throws(function() {

@@ -63,5 +62,3 @@ newer();

describe('config.ext', function() {
it('must be a string', function() {
assert.throws(function() {

@@ -78,3 +75,2 @@ newer({dest: 'foo', ext: 1});

describe('config.map', function() {
it('must be a function', function() {

@@ -95,7 +91,5 @@ assert.throws(function() {

});
});
describe('config.extra', function() {
beforeEach(function() {

@@ -151,3 +145,5 @@ mock({

it('must let other files through stream if an "extra" is newer', function(done) {
it('must let other files through stream if an "extra" is newer', function(
done
) {
var stream = newer({dest: 'collected', extra: 'imported'});

@@ -172,7 +168,5 @@

});
});
describe('dest dir that does not exist', function() {
beforeEach(function() {

@@ -207,7 +201,5 @@ mock({

});
});
describe('dest file that does not exist', function() {
beforeEach(function() {

@@ -243,7 +235,5 @@ mock({

});
});
describe('empty dest dir', function() {
beforeEach(function() {

@@ -279,7 +269,5 @@ mock({

});
});
describe('dest dir with one older file', function() {
beforeEach(function() {

@@ -320,7 +308,5 @@ mock({

});
});
describe('dest dir with one newer file', function() {
beforeEach(function() {

@@ -370,7 +356,5 @@ mock({

});
});
describe('dest dir with two newer and one older file', function() {
beforeEach(function() {

@@ -428,7 +412,5 @@ mock({

});
});
describe('dest file with first source file newer', function() {
beforeEach(function() {

@@ -478,7 +460,5 @@ mock({

});
});
describe('dest file with second source file newer', function() {
beforeEach(function() {

@@ -528,7 +508,5 @@ mock({

});
});
describe('dest file with last source file newer', function() {
beforeEach(function() {

@@ -578,7 +556,5 @@ mock({

});
});
describe('dest file with no newer source files', function() {
beforeEach(function() {

@@ -628,7 +604,5 @@ mock({

});
});
describe('dest file ext and two files', function() {
beforeEach(function() {

@@ -678,7 +652,5 @@ mock({

});
});
describe('custom mapping between source and dest', function() {
beforeEach(function() {

@@ -758,3 +730,2 @@ mock({

});
});

@@ -765,3 +736,3 @@

mock({
'q': mock.file({
q: mock.file({
mtime: new Date(100)

@@ -790,5 +761,3 @@ }),

});
});
});

Sorry, the diff of this file is not supported yet

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