-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from tschaub/reconfig
Reconfigure modified targets after successful runs. This allows composed tasks to use template syntax for files config.
- Loading branch information
Showing
5 changed files
with
162 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
var assert = require('assert'); | ||
var path = require('path'); | ||
|
||
|
||
/** | ||
* @param {Object} grunt Grunt. | ||
*/ | ||
module.exports = function(grunt) { | ||
|
||
var log = []; | ||
|
||
grunt.initConfig({ | ||
newer: { | ||
options: { | ||
timestamps: path.join(__dirname, '.cache') | ||
} | ||
}, | ||
modified: { | ||
one: { | ||
files: [{ | ||
expand: true, | ||
cwd: 'src/', | ||
src: 'one.coffee', | ||
dest: 'dest/', | ||
ext: '.js' | ||
}] | ||
}, | ||
all: { | ||
files: [{ | ||
expand: true, | ||
cwd: 'src/', | ||
src: '**/*.coffee', | ||
dest: 'dest/', | ||
ext: '.js' | ||
}] | ||
}, | ||
none: { | ||
src: [] | ||
} | ||
}, | ||
log: { | ||
all: { | ||
files: [{ | ||
expand: true, | ||
cwd: 'src/', | ||
src: '**/*.coffee', | ||
dest: 'dest/', | ||
ext: '.js' | ||
}], | ||
getLog: function() { | ||
return log; | ||
} | ||
} | ||
}, | ||
assert: { | ||
that: { | ||
getLog: function() { | ||
return log; | ||
} | ||
} | ||
} | ||
}); | ||
|
||
grunt.loadTasks('../../../tasks'); | ||
grunt.loadTasks('../../../test/tasks'); | ||
|
||
grunt.registerTask('assert-reconfigured', function() { | ||
var config = grunt.config.get(['log', 'all']); | ||
assert.deepEqual(Object.keys(config).sort(), ['files', 'getLog']); | ||
var files = config.files; | ||
assert.equal(files.length, 1); | ||
assert.deepEqual(Object.keys(files[0]).sort(), | ||
['cwd', 'dest', 'expand', 'ext', 'src']); | ||
assert.equal(files[0].src, '**/*.coffee'); | ||
}); | ||
|
||
grunt.registerTask('default', function() { | ||
|
||
grunt.task.run([ | ||
// run the log task with newer, expect all files | ||
'newer:log', | ||
'assert:that:modified:all', | ||
|
||
// HFS+ filesystem mtime resolution | ||
'wait:1001', | ||
|
||
// modify one file | ||
'modified:one', | ||
|
||
// run assert task again, expect one file | ||
'newer:log', | ||
'assert:that:modified:one', | ||
|
||
// check that log:all task has been reconfigured with original config | ||
'assert-reconfigured' | ||
]); | ||
|
||
}); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
coffee = | ||
is: 'good' | ||
hot: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
semicolons = true | ||
coffee = true | ||
semicolons = false if coffee |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
var path = require('path'); | ||
|
||
var helper = require('./helper'); | ||
|
||
var name = 'newer-reconfigure'; | ||
var gruntfile = path.join(name, 'gruntfile.js'); | ||
|
||
describe(name, function() { | ||
var fixture; | ||
|
||
it('runs the default task (see ' + gruntfile + ')', function(done) { | ||
this.timeout(3000); | ||
helper.buildFixture(name, function(error, dir) { | ||
fixture = dir; | ||
done(error); | ||
}); | ||
}); | ||
|
||
after(function(done) { | ||
helper.afterFixture(fixture, done); | ||
}); | ||
|
||
}); |