grunt-newer
Advanced tools
Comparing version 0.6.0 to 0.6.1
# Change Log | ||
## 0.6.1 | ||
* When `src` and `dest` files are the same, the previous run time is considered (see #24) | ||
## 0.6.0 | ||
@@ -4,0 +8,0 @@ |
@@ -30,3 +30,3 @@ var assert = require('assert'); | ||
options: { | ||
jshintrc: '.jshintrc' | ||
jshintrc: true | ||
}, | ||
@@ -40,5 +40,2 @@ gruntfile: { | ||
tests: { | ||
options: { | ||
jshintrc: 'test/.jshintrc' | ||
}, | ||
src: testSrc | ||
@@ -45,0 +42,0 @@ }, |
@@ -78,2 +78,11 @@ var crypto = require('crypto'); | ||
} | ||
if (obj.src && obj.src.length === 1 && obj.src[0] === obj.dest) { | ||
// when src and dest are same, compare to previous | ||
return filterPathsByTime(obj.src, previous, function(err, src) { | ||
if (err) { | ||
return done(err); | ||
} | ||
done(null, {src: src, dest: obj.dest}); | ||
}); | ||
} | ||
return anyNewer(obj.src, stats.mtime, function(err, any) { | ||
@@ -80,0 +89,0 @@ done(err, any && obj); |
{ | ||
"name": "grunt-newer", | ||
"description": "Run Grunt tasks with only those source files modified since the last successful run.", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"homepage": "https://github.com/tschaub/grunt-newer", | ||
@@ -32,13 +32,12 @@ "author": { | ||
"devDependencies": { | ||
"grunt": "0.4.1", | ||
"grunt-cli": "0.1.9", | ||
"grunt": "0.4.2", | ||
"grunt-cli": "0.1.11", | ||
"grunt-contrib-watch": "0.5.3", | ||
"grunt-contrib-jshint": "0.6.4", | ||
"chai": "1.7.2", | ||
"grunt-cafe-mocha": "0.1.8", | ||
"wrench": "1.5.1", | ||
"grunt-contrib-jshint": "0.7.2", | ||
"chai": "1.8.1", | ||
"grunt-cafe-mocha": "0.1.10", | ||
"wrench": "1.5.4", | ||
"tmp": "0.0.21", | ||
"grunt-contrib-clean": "0.5.0", | ||
"mock-fs": "0.2.0", | ||
"rewire": "2.0.0" | ||
"mock-fs": "2.x" | ||
}, | ||
@@ -55,4 +54,5 @@ "peerDependencies": { | ||
"dependencies": { | ||
"async": "0.2.9" | ||
"async": "0.2.9", | ||
"rimraf": "2.2.4" | ||
} | ||
} |
@@ -130,1 +130,15 @@ # grunt-newer | ||
[![Current Status](https://secure.travis-ci.org/tschaub/grunt-newer.png?branch=master)](https://travis-ci.org/tschaub/grunt-newer) | ||
## Known limitations | ||
The `newer` task relies on Grunt's convention for specifying [`src`/`dest` mappings](http://gruntjs.com/configuring-tasks#files). So it should be expected to work with two types of tasks: | ||
1) Tasks that specify both `src` and `dest` files. In this case, the task prefixed by `newer` will be configured to run with `src` files that are newer than the corresponding `dest` file (based on the `mtime` of files). | ||
2) Tasks that specify only `src` files. In this case, the task prefixed by `newer` will be configured to run with `src` files that are newer than the previous successful run of the same task. | ||
The `newer` task will *not* work as a prefix for the following tasks: | ||
* [`grunt-rsync`](http://npmjs.org/package/grunt-rsync) - Though this task specifies `src` and `dest` files, the `dest` file is not generated based on `src` files (instead it is a directory). | ||
* [`grunt-spritesmith`](https://npmjs.org/package/grunt-spritesmith) - This task uses multiple `src` images to produce `destImg` and `destCSS` files. Instead use the [`grunt-spritely`](https://npmjs.org/package/grunt-spritely) task configured with `src` and `dest` files. |
@@ -5,2 +5,3 @@ var fs = require('fs'); | ||
var async = require('async'); | ||
var rimraf = require('rimraf'); | ||
@@ -161,2 +162,24 @@ var util = require('../lib/util'); | ||
grunt.registerTask( | ||
'newer-clean', 'Remove cached timestamps.', function(name, target) { | ||
var done = this.async(); | ||
/** | ||
* This intentionally only works with the default cache dir. If a | ||
* custom cache dir is provided, it is up to the user to keep it clean. | ||
*/ | ||
var cacheDir = path.join(__dirname, '..', '.cache'); | ||
if (name && target) { | ||
cacheDir = util.getStampPath(cacheDir, name, target); | ||
} else if (name) { | ||
cacheDir = path.join(cacheDir, name); | ||
} | ||
if (grunt.file.exists(cacheDir)) { | ||
grunt.log.writeln('Cleaning ' + cacheDir); | ||
rimraf(cacheDir, done); | ||
} else { | ||
done(); | ||
} | ||
}); | ||
}; |
var mock = require('mock-fs'); | ||
var rewire = require('rewire'); | ||
var assert = require('../helper').assert; | ||
var util = require('../../lib/util'); | ||
var fs = mock.fs(); | ||
var util = rewire('../../lib/util'); | ||
util.__set__('fs', fs); | ||
@@ -15,3 +12,3 @@ describe('util', function() { | ||
beforeEach(function() { | ||
fs._reconfigure({ | ||
mock({ | ||
src: { | ||
@@ -32,2 +29,3 @@ js: { | ||
}); | ||
afterEach(mock.restore); | ||
@@ -72,3 +70,3 @@ it('calls callback with files newer than provided time', function(done) { | ||
beforeEach(function() { | ||
fs._reconfigure({ | ||
mock({ | ||
src: { | ||
@@ -89,2 +87,3 @@ js: { | ||
}); | ||
afterEach(mock.restore); | ||
@@ -130,3 +129,3 @@ var paths = [ | ||
beforeEach(function() { | ||
fs._reconfigure({ | ||
mock({ | ||
src: { | ||
@@ -162,2 +161,3 @@ js: { | ||
}); | ||
afterEach(mock.restore); | ||
@@ -196,2 +196,28 @@ it('provides all files if any is newer than dest', function(done) { | ||
it('provides newer src files if same as dest', function(done) { | ||
var files = [{ | ||
src: ['src/js/a.js'], | ||
dest: 'src/js/a.js' | ||
}, { | ||
src: ['src/js/b.js'], | ||
dest: 'src/js/b.js' | ||
}, { | ||
src: ['src/js/c.js'], | ||
dest: 'src/js/c.js' | ||
}]; | ||
util.filterFilesByTime(files, new Date(150), function(err, results) { | ||
assert.isNull(err); | ||
assert.equal(results.length, 2); | ||
var first = results[0]; | ||
assert.equal(first.dest, 'src/js/b.js'); | ||
assert.equal(first.src.length, 1); | ||
assert.deepEqual(first.src, files[1].src); | ||
var second = results[1]; | ||
assert.equal(second.dest, 'src/js/c.js'); | ||
assert.equal(second.src.length, 1); | ||
assert.deepEqual(second.src, files[2].src); | ||
done(); | ||
}); | ||
}); | ||
it('provides files newer than previous if no dest', function(done) { | ||
@@ -198,0 +224,0 @@ var files = [{ |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
47533
10
1286
144
1
3
38
+ Addedrimraf@2.2.4
+ Addedgraceful-fs@2.0.3(transitive)
+ Addedrimraf@2.2.4(transitive)