-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgruntfile.js
124 lines (116 loc) · 3.66 KB
/
gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
module.exports = grunt => {
require('jit-grunt')(grunt);
grunt.initConfig({
path: {
tasks: 'tasks',
source: {
root: 'tests/fixtures',
single: '<%= path.source.root %>/single',
multiple: '<%= path.source.root %>/multiple',
nested: '<%= path.source.root %>/nested'
// withError: '<%= path.source.root %>/withError'
},
build: {
root: 'build',
singleWithDefaults: '<%= path.build.root %>/singleWithDefaults.json',
multipleWithDefaults:
'<%= path.build.root %>/multipleWithDefaults.json',
nestedWithDefaults: '<%= path.build.root %>/nestedWithDefaults.json',
expandedNestedWithDefaults:
'<%= path.build.root %>/expandedNestedWithDefaults',
notImage: '<%= path.build.root %>/not-image.json',
singleWithProcessName:
'<%= path.build.root %>/singleWithProcessName.json',
singleWithProcessEntry:
'<%= path.build.root %>/singleWithProcessEntry.json',
singleWithProcessSizes:
'<%= path.build.root %>/singleWithProcessSizes.json',
singleWithConfigObject: 'configObjectTest',
singleWithConfigObjectAndDest: {
dest: '<%= path.build.root %>/singleWithConfigObjectAndDest.json',
property: 'configObjectAndDestTest'
}
}
}
});
grunt.loadTasks(grunt.config('path.tasks'));
grunt.config('image_size', {
singleWithDefaults: {
src: '<%= path.source.single %>/*',
dest: '<%= path.build.singleWithDefaults %>'
},
multipleWithDefaults: {
src: '<%= path.source.multiple %>/*',
dest: '<%= path.build.multipleWithDefaults %>'
},
nestedWithDefaults: {
src: '<%= path.source.nested %>/{,**/}*',
dest: '<%= path.build.nestedWithDefaults %>'
},
expandedNestedWithDefaults: {
files: [
{
expand: true,
cwd: '<%= path.source.nested %>',
src: ['{,**/}*'],
ext: '.json',
dest: '<%= path.build.expandedNestedWithDefaults %>'
}
]
},
singleWithProcessName: {
options: {
processName: name =>
name.replace(grunt.template.process('<%= path.source.single %>'), '')
},
src: '<%= path.source.single %>/*',
dest: '<%= path.build.singleWithProcessName %>'
},
singleWithProcessEntry: {
options: {
processEntry: entry => {
entry.test = 'This is test a property';
return entry;
}
},
src: '<%= path.source.single %>/*',
dest: '<%= path.build.singleWithProcessEntry %>'
},
singleWithProcessSizes: {
options: {
processSizes: sizes => {
sizes.push('This is a testing value');
return sizes;
}
},
src: '<%= path.source.single %>/*',
dest: '<%= path.build.singleWithProcessSizes %>'
},
singleWithConfigObject: {
options: {
configObject: '<%= path.build.singleWithConfigObject %>'
},
src: '<%= path.source.single %>/*'
},
singleWithConfigObjectAndDest: {
options: {
configObject: '<%= path.build.singleWithConfigObjectAndDest.property %>'
},
src: '<%= path.source.single %>/*',
dest: '<%= path.build.singleWithConfigObjectAndDest.dest %>'
},
notImage: {
src: '<%= path.source.notImage %>/*',
dest: '<%= path.build.notImage %>'
}
});
grunt.config('clean', {
build: {
src: ['<%= path.build.root %>/*']
}
});
// This is just for manual testing. It isn't used anywhere
// Instead, Jest manually calls task which it needs to test
grunt.registerTask('test', ['clean', 'image_size']);
return grunt;
};