tschaub / grunt-newer

Configure Grunt tasks to run with newer files only.
https://npmjs.org/package/grunt-newer
MIT License
945 stars 53 forks source link

newer always says [no files] with rsync task #21

Closed mnpenner closed 10 years ago

mnpenner commented 10 years ago

I'm trying to use newer to rsync any modified files up to my dev server. Here's my setup:

watch: {
    upload: {
        files: ['**/*'],
        tasks: ['newer:rsync:dev']
    },
},

rsync: {
    options: {
        args: ['--verbose'],
        exclude: ['.*','node_modules','sql','artifacts','session','logs','cache'],
        recursive: true,
        syncDestIgnoreExcl: true
    },
    dev: {
        options: {
            src: './',
            dest: '/path/to/project',
            host: 'dev3',
        }
    }
},

When I run the watch with --verbose and the modify a file, it tells me:

Running "newer:rsync:dev" (newer) task
Options: cache="/path/to/project/node_modules/grunt-newer/.cache"
File: [no files]
No newer files to process.

If it's trying to compare the source files against the rsync dest, that would be incorrect, because those live on a different server.... there don't appear to be any options to suppress this behaviour, however.

tschaub commented 10 years ago

Thanks for the report @mnbayazit. The newer task uses Grunt's convention for specifying src/dest pairs. Unfortunately, it looks like the rsync task has a different interpretation of the dest configuration property.

As mentioned in the rsync readme:

this task does not use Grunt's in-built path expanding and globbing

So I'm afraid the two tasks will not work well together. I'll try to think about ways that it could be made to work, but I don't have any immediate suggestions.

mnpenner commented 10 years ago

My understanding is that newer will only check against dest if it exists. Otherwise, it keeps an internal cache to determine if the files have changed. Can't you add an option to suppress looking at dest even if it is present? I think that might be the easiest solution.

tschaub commented 10 years ago

The current logic is that if dest is present in a task's config but isn't a file that exists, use all src files. This allows tasks to run properly after clean (in cases where clean removes dest files).

An option to ignore all dest files would work.

  newer: {
    options: {
      dest: false
    }
  }

But this would be a "global" option. That is, all tasks prefixed with newer would behave in the same way.

The same kind of option could be used to tell newer that there are multiple dest files. E.g. to support grunt-spritely (see #22), the following configuration could be used:

  newer: {
    options: {
      dest: ['build/images/sprite.jpg', 'build/css/style.css']
    }
  }

In both of these cases, newer would be configured to work with a specific task. The current options (only one is documented) are meant to work when prefixing multiple tasks with newer.

I'd like to come up with a solution to override the default behavior on a task-by-task basis. The other experimental option (isNewer, see #18), should also be a per-target option.

This could be accomplished by providing options to newer using the target task's name (or name:target for multitasks).

E.g.

  newer: {
    rsync: {
      ignoreDest: true
    }
  }

I'd like to come up with something that is flexible enough to use on multiple tasks. Suggestions welcome.

tschaub commented 10 years ago

No progress on a workaround for this yet. I'll reopen if anything changes.