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