Is there a way to automatically generate karma.conf.js with a grumbling task?

I am using a modified version of the grunt file that comes with the angularjs generator of the Yeoman.io database, and the grunt-bower-install command is convenient for keeping my base index.html file up to date with the Bower dependencies.

However, when I do bower install (package) --save and then grunt bower-install, my updates are index.html, but my karma.conf.js is not updated, that is, I need to manually add a new file to the list of files to download when karma starts the test suite (otherwise the injector does not try to inject a nonexistent package).

Is there any easy way to add this to my workflow? This is not the end of the world, but it is one of those easily forgotten things.

+3
source share
1 answer

I really came up with a solution just for this problem. Check out https://github.com/stephenplusplus/grunt-bower-install/issues/35#issuecomment-32084805

'bower-install': {
  app: {
    src: '<%= yeoman.app %>/index.html',
    ignorePath: '<%= yeoman.app %>/'
  },
  test: {
    src: 'karma.conf.js',
    fileTypes: {
      js: {
        block: /(([\s\t]*)\/\/\s*bower:*(\S*))(\n|\r|.)*?(\/\/\s*endbower)/gi,
        detect: {
          js: /'.*\.js'/gi
        },
        replace: {
          js: '\'{{filePath}}\','
        }
      }
    }
  }
}
+4
source

All Articles