Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

watch-Event should be fired at start-up for each file, when atBegin is true #523

Open
0815fox opened this issue Oct 6, 2016 · 0 comments

Comments

@0815fox
Copy link

0815fox commented Oct 6, 2016

I have a task configured as follows:

...
watch: {
            'convert-model': {
                files: [
                    'src/ch.actifsource.cloud.model/**/*.asr'
                ],
                tasks: [],
                options: {
                    spawn: true,
                    interrupt: false,
                    atBegin: true
                },
            }
...
grunt.event.on('watch', function(Action, FilePath, Target) {
        if (Target === 'convert-model') {
            switch (Action) {
                case 'added':
                case 'changed':
                    var TargetPath = convertModelTargetPath(FilePath);
                    grunt.log.writeln('Converting model file ' + FilePath + ' to: ' + TargetPath);
                    myOwnFileConverterFunction(FilePath,TargetPath);
                    break;
                case 'deleted':
                var TargetPath = convertModelTargetPath(FilePath);
                    grunt.log.writeln('Deleting model file from: ' + TargetPath);
                    break;
                default:
                    grunt.log.writeln('Unknown action on ' + FilePath + ': ' + Action);
            }

        }
    });

I want my watch:convert-model task to convert each target file using my own converter function at startup and then each as it changes. However, the event is only emitted on changes after the watch task started.
Request:
When atBegin is set, the event should also be called for each file which exists at the beginning. However, I am not sure, whether that should be seen as added or modified-action. It may even make sense to define a new action string, e.g. atBegin, then one could easily filter those out when atBegin is set, but the custom code shall not be executed for atBegin-Modifications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant