generator-angular icon indicating copy to clipboard operation
generator-angular copied to clipboard

Newer task and src property

Open lukaszprus opened this issue 12 years ago • 4 comments

This is the unmodified jshint task from my Gruntfile

    // Make sure code styles are up to par and there are no obvious mistakes
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish')
      },
      all: [
        'Gruntfile.js',
        '<%= yeoman.app %>/scripts/{,*/}*.js'
      ],
      test: {
        options: {
          jshintrc: 'test/.jshintrc'
        },
        src: ['test/spec/{,*/}*.js']
      }
    },

Compare

grunt newer:jshint:test

and

grunt newer:jshint:all

The first one works correctly and doesn't execute jshint:test when there's no changes since the last successful run (As per documentation here: https://www.npmjs.org/package/grunt-newer). So I get "No new files to process" in my console when I run it multiple times without any changes to src files.

The second command doesn't behave in the same way and it looks like newer task needs 'src' property to be set explicitly in jshint:all configuration. This seems to be working fine for me:

    // Make sure code styles are up to par and there are no obvious mistakes
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish')
      },
      all: {
        src: ['Gruntfile.js', '<%= yeoman.app %>/scripts/{,*/}*.js']
      },
      test: {
        options: {
          jshintrc: 'test/.jshintrc'
        },
        src: ['test/spec/{,*/}*.js']
      }
    },

lukaszprus avatar Mar 19 '14 13:03 lukaszprus

Also check 'Known limitations' at the bottom of https://www.npmjs.org/package/grunt-newer. It kind of says that 'src' is needed for newer task to work correctly. Other src-dest file mapping formats might not be supported.

lukaszprus avatar Mar 19 '14 13:03 lukaszprus

@lucasprus feel free to submit a pr for this

eddiemonge avatar Mar 27 '14 23:03 eddiemonge

fixed in https://github.com/yeoman/generator-angular/commit/1c37e2d0691530ab4fa7a730e00acebd12566955

eddiemonge avatar Mar 28 '14 17:03 eddiemonge

check this out https://github.com/gruntjs/grunt-contrib-watch#compiling-files-as-needed js: { files: ['<%= yeoman.app %>/scripts/{,/}.js'], tasks: ['newer:jshint:all'], options: { livereload: '<%= connect.options.livereload %>', spawn: false, //i think need this } }, in my yo angular environment helped because, newer:jshint:all run very very slow, (i dont know why), about 10sec, with spawn:false run 0.09s

extdevelopment avatar Dec 07 '14 16:12 extdevelopment