component.js 462 B

12345678910111213141516171819
  1. // automatically fill in component.json's script field
  2. module.exports = function (grunt) {
  3. grunt.registerTask('component', function () {
  4. var jsRE = /\.js$/
  5. var component = grunt.file.readJSON('component.json')
  6. component.scripts = []
  7. grunt.file.recurse('src', function (file) {
  8. if (jsRE.test(file)) {
  9. component.scripts.push(file)
  10. }
  11. })
  12. grunt.file.write('component.json', JSON.stringify(component, null, 2))
  13. })
  14. }