-
Notifications
You must be signed in to change notification settings - Fork 20
/
Gruntfile.js
130 lines (126 loc) · 3.89 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
125
126
127
128
129
130
module.exports = function (grunt) {
'use strict';
function getExamplesForPages(examples) {
var result = {};
examples.forEach(function(example) {
result['build/examples/'+example+'/index.html'] = [baseDir+example+'/index.tpl.html', baseDir+example+'/data.json'];
});
return result;
}
function getExamplesForIndex(examples) {
return examples.map(function(example) {
return {
name: example,
data: baseDir+example+'/data.json',
html: baseDir+example+'/index.tpl.html',
js: baseDir+example+'/script.js'
};
});
}
var baseDir = 'docs/examples/',
examples = [
'simple-marker',
'color-marker',
'controls',
'markers-array',
'clusterize',
'markers-text',
'balloons',
'update-center',
'map-toggle',
'multi-map'
];
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
karma: {
options: {
configFile: 'karma.conf.js',
browsers: ['Firefox']
},
unit: {},
travis: {}
},
jshint: {
files: ['<%= pkg.name %>.js']
},
concat: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
main: {
src: ['<%= pkg.name %>.js'],
dest: 'build/<%= pkg.name %>.js'
}
},
uglify: {
main: {
src: 'build/<%= pkg.name %>.js',
dest: 'build/<%= pkg.name %>.min.js'
}
},
examples: {
options: {
layout: 'docs/example.tpl.html'
},
examples: {
files: getExamplesForPages(examples)
}
},
index: {
options: {
layout: 'docs/index.tpl.html',
dest: 'build/index.html'
},
files: {
readme: 'README.md',
examples: getExamplesForIndex(examples),
contrib: 'CONTRIBUTING.md'
}
},
copy: {
main: {
expand: true,
cwd: 'docs/',
src: ['**', '!**/*.tpl.html'],
dest: 'build/'
}
},
buildcontrol: {
options: {
dir: 'build',
connectCommits: false,
commit: true,
push: true,
message: 'Built %sourceName% from commit %sourceCommit% on branch %sourceBranch%'
},
pages: {
options: {
remote: '[email protected]:just-boris/angular-ymaps.git',
branch: 'gh-pages'
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-build-control');
grunt.loadTasks('tasks/');
grunt.registerTask('test', 'Run tests on singleRun karma server', function() {
if (process.env.TRAVIS) {
//this task can be executed in Travis-CI
grunt.task.run('karma:travis');
} else {
grunt.task.run('karma:unit');
}
});
grunt.registerTask('build', ['jshint', 'test', 'concat', 'uglify']);
grunt.registerTask('demo', ['index', 'examples', 'copy']);
grunt.registerTask('demo-notests', ['jshint', 'concat', 'uglify', 'demo']);
grunt.registerTask('default', ['build', 'demo']);
grunt.registerTask('build-gh', ['default', 'buildcontrol:pages']);
return grunt;
};