Socket
Socket
Sign inDemoInstall

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 0.4.0 to 0.5.0

15

index.js

@@ -28,2 +28,6 @@ var Transform = require('stream').Transform;

if (options.map && typeof options.map !== 'function') {
throw new PluginError('Requires map to be a function');
}
/**

@@ -42,2 +46,8 @@ * Path to destination directory or file.

/**
* Optional function for mapping relative source files to destination files.
* @type {function(string): string}
*/
this._map = options.map;
/**
* Promise for the dest file/directory stats.

@@ -82,3 +92,3 @@ * @type {[type]}

this._destStats.then(function(destStats) {
if (destStats.isDirectory() || self._ext) {
if (destStats.isDirectory() || self._ext || self._map) {
// stat dest/relative file

@@ -90,2 +100,5 @@ var relative = srcFile.relative;

relative;
if (self._map) {
destFileRelative = self._map(destFileRelative);
}
return Q.nfcall(fs.stat, path.join(self._dest, destFileRelative));

@@ -92,0 +105,0 @@ } else {

14

package.json
{
"name": "gulp-newer",
"version": "0.4.0",
"version": "0.5.0",
"description": "Only pass through newer source files",

@@ -34,12 +34,12 @@ "homepage": "https://github.com/tschaub/gulp-newer",

"devDependencies": {
"jshint": "~2.4.1",
"mocha": "~1.17.0",
"gulp": "~3.3.4",
"chai": "~1.8.1",
"mock-fs": "~2.1.1"
"jshint": "~2.5.10",
"mocha": "~2.0.1",
"gulp": "~3.8.10",
"chai": "~1.10.0",
"mock-fs": "~2.3.2"
},
"dependencies": {
"kew": "~0.3.1",
"gulp-util": "~2.2.10"
"gulp-util": "~3.0.1"
}
}

@@ -72,2 +72,3 @@ # `gulp-newer`

* **options.ext** - `string` Source files will be matched to destination files with the provided extension (e.g. '.css').
* **options.map** - `function` Map relative source paths to relative destination paths (e.g. `function(relativePath) { return relativePath + '.bak'; }`)

@@ -74,0 +75,0 @@ Create a [transform stream](http://nodejs.org/api/stream.html#stream_class_stream_transform_1) that passes through files whose modification time is more recent than the corresponding destination file's modification time.

@@ -59,5 +59,5 @@ var Transform = require('stream').Transform;

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

@@ -73,2 +73,16 @@ newer({dest: 'foo', ext: 1});

describe('config.map', function() {
it('must be a function', function() {
assert.throws(function() {
newer({dest: 'foo', map: 1});
});
assert.throws(function() {
newer({dest: 'foo', map: 'bar'});
});
});
});
describe('dest dir that does not exist', function() {

@@ -569,2 +583,56 @@

describe('custom mapping between source and dest', function() {
beforeEach(function() {
mock({
'file1.ext1': mock.file({
content: 'file1 content',
mtime: new Date(100)
}),
'file2.ext1': mock.file({
content: 'file2 content',
mtime: new Date(100)
}),
dest: {
'file1.ext2': mock.file({
content: 'file1 content',
mtime: new Date(100)
}),
'file2.ext2': mock.file({
content: 'file2 content',
mtime: new Date(50)
})
}
});
});
afterEach(mock.restore);
it('passes through one newer file', function(done) {
var stream = newer({
dest: 'dest',
map: function(destPath) {
return destPath.replace('.ext1', '.ext2');
}
});
var paths = ['file1.ext1', 'file2.ext1'];
var calls = 0;
stream.on('data', function(file) {
assert.equal(file.path, path.resolve('file2.ext1'));
++calls;
});
stream.on('error', done);
stream.on('end', function() {
assert.equal(calls, 1);
done();
});
write(stream, paths);
});
});
});

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