gulp-newer
Advanced tools
Comparing version 1.0.0 to 1.1.0
14
index.js
@@ -23,3 +23,3 @@ var Transform = require('stream').Transform; | ||
options = {dest: options}; | ||
} else if (typeof options.dest !== 'string') { | ||
} else if (options.dest && typeof options.dest !== 'string') { | ||
throw new PluginError(PLUGIN_NAME, 'Requires a dest string'); | ||
@@ -36,2 +36,6 @@ } | ||
if (!options.dest && !options.map) { | ||
throw new PluginError(PLUGIN_NAME, 'Requires either options.dest or options.map or both'); | ||
} | ||
/** | ||
@@ -59,3 +63,3 @@ * Path to destination directory or file. | ||
*/ | ||
this._destStats = Q.nfcall(fs.stat, this._dest); | ||
this._destStats = this._dest ? Q.nfcall(fs.stat, this._dest) : Q.resolve(null); | ||
@@ -96,3 +100,3 @@ /** | ||
this._destStats.then(function(destStats) { | ||
if (destStats.isDirectory() || self._ext || self._map) { | ||
if ((destStats && destStats.isDirectory()) || self._ext || self._map) { | ||
// stat dest/relative file | ||
@@ -107,3 +111,5 @@ var relative = srcFile.relative; | ||
} | ||
return Q.nfcall(fs.stat, path.join(self._dest, destFileRelative)); | ||
var destFileJoined = self._dest ? | ||
path.join(self._dest, destFileRelative) : destFileRelative; | ||
return Q.nfcall(fs.stat, destFileJoined); | ||
} else { | ||
@@ -110,0 +116,0 @@ // wait to see if any are newer, then pass through all |
{ | ||
"name": "gulp-newer", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Only pass through newer source files", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/tschaub/gulp-newer", |
34
spec.js
@@ -74,3 +74,2 @@ /* eslint-env mocha */ | ||
it('must be a function', function() { | ||
assert.throws(function() { | ||
@@ -84,2 +83,9 @@ newer({dest: 'foo', map: 1}); | ||
}); | ||
it('makes the dest config optional', function() { | ||
assert.doesNotThrow(function() { | ||
newer({map: function() {}}); | ||
}); | ||
}); | ||
}); | ||
@@ -633,2 +639,28 @@ | ||
}); | ||
it('allows people to join to dest themselves', function(done) { | ||
var stream = newer({ | ||
map: function(destPath) { | ||
return path.join('dest', 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); | ||
}); | ||
}); | ||
@@ -635,0 +667,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24126
697