You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.3 KiB

  1. /*
  2. * grunt-contrib-copy
  3. * http://gruntjs.com/
  4. *
  5. * Copyright (c) 2012 Chris Talkington, contributors
  6. * Licensed under the MIT license.
  7. */
  8. module.exports = function(grunt) {
  9. 'use strict';
  10. // Make an empty dir for testing as git doesn't track empty folders.
  11. grunt.file.mkdir('test/fixtures/empty_folder');
  12. grunt.file.mkdir('test/expected/copy_test_mix/empty_folder');
  13. // Project configuration.
  14. grunt.initConfig({
  15. jshint: {
  16. all: [
  17. 'Gruntfile.js',
  18. 'tasks/*.js',
  19. '<%= nodeunit.tests %>'
  20. ],
  21. options: {
  22. jshintrc: '.jshintrc'
  23. }
  24. },
  25. // Before generating any new files, remove any previously-created files.
  26. clean: {
  27. test: ['tmp']
  28. },
  29. test_vars: {
  30. name: 'grunt-contrib-copy',
  31. version: '0.1.0',
  32. match: 'folder_one/*'
  33. },
  34. // Configuration to be run (and then tested).
  35. copy: {
  36. main: {
  37. files: [
  38. {expand: true, cwd: 'test/fixtures', src: ['*.*'], dest: 'tmp/copy_test_files/'},
  39. {expand: true, cwd: 'test/fixtures', src: ['**'], dest: 'tmp/copy_test_mix/'},
  40. {expand: true, cwd: 'test/fixtures', src: ['<%= test_vars.match %>'], dest: 'tmp/copy_test_v<%= test_vars.version %>/'}
  41. ]
  42. },
  43. flatten: {
  44. files: [
  45. {expand: true, flatten: true, filter: 'isFile', src: ['test/fixtures/**'], dest: 'tmp/copy_test_flatten/'}
  46. ]
  47. },
  48. single: {
  49. files: [
  50. {src: ['test/fixtures/test.js'], dest: 'tmp/single.js'}
  51. ]
  52. },
  53. verbose: {
  54. files: [
  55. {expand: true, src: ['test/fixtures/**'], dest: 'tmp/copy_test_verbose/'}
  56. ]
  57. }
  58. },
  59. // Unit tests.
  60. nodeunit: {
  61. tests: ['test/*_test.js']
  62. }
  63. });
  64. // Actually load this plugin's task(s).
  65. grunt.loadTasks('tasks');
  66. // These plugins provide necessary tasks.
  67. grunt.loadNpmTasks('grunt-contrib-jshint');
  68. grunt.loadNpmTasks('grunt-contrib-clean');
  69. grunt.loadNpmTasks('grunt-contrib-nodeunit');
  70. grunt.loadNpmTasks('grunt-contrib-internal');
  71. // Whenever the "test" task is run, first clean the "tmp" dir, then run this
  72. // plugin's task(s), then test the result.
  73. grunt.registerTask('test', ['clean', 'copy', 'nodeunit']);
  74. // By default, lint and run all tests.
  75. grunt.registerTask('default', ['jshint', 'test', 'build-contrib']);
  76. };