Skip to content

Loading…

File tasks within a namespace always execute regardless of whether file dependencies have changes. #72

Merged
merged 2 commits into from

2 participants

@Page-

I encountered this problem earlier today that if you have a file task within a namespace which depends upon a file then it will always execute because it checks for the ctime of namespace:file which does not exist as opposed to just the name of the file.
The pull request includes a test for this behaviour so you should be able to easily replicate.

Page added some commits
Page Add a test to show that a FileTask within a namespace always executes…
… regardless of whether the file it depends upon has actually changed.

To run the test run jake bar:setup and then jake bar:src2.txt repeatedly and it will display 'doing src2.txt file-task' each time.
aeef316
Page Fix a FileTask within a namespace always executing regardless of whet…
…her the file it depends upon has actually changed.
e8d62f7
@mde mde merged commit a4f5c65 into jakejs:master
@mde

Merged, thanks. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 27, 2011
  1. Add a test to show that a FileTask within a namespace always executes…

    Page committed
    … regardless of whether the file it depends upon has actually changed.
    
    To run the test run jake bar:setup and then jake bar:src2.txt repeatedly and it will display 'doing src2.txt file-task' each time.
  2. Fix a FileTask within a namespace always executing regardless of whet…

    Page committed
    …her the file it depends upon has actually changed.
This page is out of date. Refresh to see the latest.
Showing with 16 additions and 3 deletions.
  1. +2 −2 lib/jake.js
  2. +14 −1 tests/Jakefile
View
4 lib/jake.js
@@ -274,7 +274,7 @@ jake = new function () {
if (task instanceof FileTask) {
try {
- stats = fs.statSync(name);
+ stats = fs.statSync(task.name);
modTime = stats.ctime;
}
catch (e) {
@@ -299,7 +299,7 @@ jake = new function () {
// If there's a valid file at the end of running the task,
// use its mod-time as last modified
try {
- stats = fs.statSync(name);
+ stats = fs.statSync(task.name);
modTime = stats.ctime;
}
// If there's still no actual file after running the file-task,
View
15 tests/Jakefile
@@ -40,7 +40,7 @@ task('fonebone', function () {
directory('foo');
-desc('File task, concating two files together');
+desc('File task, concatenating two files together');
file({'foo/concat.txt': ['foo', 'foo/src1.txt', 'foo/src2.txt']}, function () {
console.log('doing concat.txt file-task');
var data1 = fs.readFileSync('foo/src1.txt');
@@ -138,7 +138,20 @@ namespace('foo', function () {
complete();
}, 0);
}, true);
+});
+
+namespace('bar', function() {
+ directory('bar');
+
+ task({'setup': 'bar:bar'}, function() {
+ fs.writeFileSync('bar/test.txt', 'test');
+ });
+ desc('Namespaced file task, don\'t run unless the prereq file changes');
+ file({'bar/src2.txt': 'bar/test.txt'}, function () {
+ console.log('doing src2.txt file-task');
+ fs.writeFileSync('bar/src2.txt', '');
+ });
});
Something went wrong with that request. Please try again.