-
Notifications
You must be signed in to change notification settings - Fork 257
/
Gruntfile.js
118 lines (109 loc) · 2.7 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
module.exports = function (grunt) {
/**
* Load tasks
*/
grunt.loadTasks('tasks');
grunt.loadNpmTasks('grunt-prompt');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-mkdir');
/**
* Grunt config
*/
grunt.initConfig({
pkg: require('./package.json'),
clean: {
build: {
src: ['build']
}
},
mkdir: {
build: {
options: {
create: ['build']
}
}
},
generator: {
settings: {
mixin_name: null,
default_value: null,
vendors: null
}
},
version: {
settings: {
version: null
}
},
prompt: {
version: {
options: {
questions: [
{
config: 'version.settings.version',
type: 'input',
validate: function (value) {
return (value && true);
},
message: 'LESS Hat next version number? Current is ' + '<%= pkg.version %>'.green + ':'
}
]
}
},
generate: {
options: {
questions: [
{
config: 'generator.settings.mixin_name',
type: 'input',
message: 'What is the name of new mixin? (e.g. animationDelay)',
filter: function (value) {
grunt.config('generator.settings.mixin_css_name', value.replace(/([A-Z])/g, function (upperCase) {
return '-' + upperCase.toLowerCase();
}));
grunt.config('generator.settings.mixin_name | firstLetter', value[0].toUpperCase() + value.slice(1));
return value[0].toLowerCase() + value.slice(1);
},
validate: function (value) {
if (/[a-z0-9]+/i.test(value)) {
return true;
} else {
return 'Please fill only valid characters [a-zA-Z0-9].';
}
}
},
{
config: 'generator.settings.vendors',
type: 'checkbox',
message: 'For which browsers is this mixin?',
choices: [
{name: 'webkit'},
{name: 'moz'},
{name: 'opera'},
{name: 'ms'}
]
},
{
config: 'generator.settings.default_value',
type: 'input',
default: 'none',
filter: function (value) {
return '\'' + value + '\'';
},
message: 'What is default value of the mixin? Optional – you can skip'
}
]
}
}
}
});
/**
* Register tasks
*/
grunt.registerTask('version', ['prompt:version', 'iterate', 'build', 'mixins_update']);
grunt.registerTask('setup', ['clean', 'mkdir']);
grunt.registerTask('dev', ['setup', 'build', 'test']);
grunt.registerTask('generate', ['prompt:generate', 'generator']);
grunt.registerTask('contrib', ['setup', 'build', 'test', 'mixins_update', 'prefix', 'documentation']);
grunt.registerTask('default', ['setup', 'build', 'test', 'mixins_update', 'prefix', 'documentation']);
};