forked from OrdnanceSurvey/os-search
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
142 lines (121 loc) · 4.4 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
131
132
133
134
135
136
137
138
139
140
141
142
var timer = require("grunt-timer"); // used to report exact timings of individual tasks
module.exports = function (grunt) {
timer.init(grunt);
grunt.loadNpmTasks('grunt-angular-templates');
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-protractor-runner');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
dist: {
options: {
banner: '/**\n' +
' * @license <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("dd-mm-yyyy") %>\n' +
' * (c) 2015 Ordnance Survey Limited\n' +
' * License: MIT\n' +
' */\n'
},
src: ['bower_components/angular-rx/dist/rx.angular.js', 'bower_components/angular-order-object-by/src/ng-order-object-by.js', 'src/osel-search-module.js', 'src/directives/osel-search-directive.js'],
dest: 'dist/osel-search.js',
nonull: true
}
},
connect: {
server: {
options: {
port: 9001,
base: '.'
}
}
},
less: {
dist: {
files: {
'dist/osel-search.css': 'src/styles/**/*.less'
}
}
},
ngtemplates: {
dist: {
cwd: 'src',
src: 'templates/**/*.html',
dest: 'dist/<%= pkg.name %>-templates.js',
options: {
module: 'osel-search'
}
}
},
concurrent: {
dev: {
tasks: ['watch:js', 'watch:less', 'watch:templates'],
options: {
logConcurrentOutput: true
}
}
},
watch: {
js: {
files: ['src/**/*.js'],
tasks: ['jshint:all', 'concat:dist', 'uglify:dist']
},
less: {
files: ['src/styles/**/*.less'],
tasks: ['less:dist']
},
templates: {
files: ['src/templates/**/*.html'],
tasks: ['ngtemplates:dist']
}
},
jshint: {
all: ['src/**/*.js']
},
protractor: {
all: { // Grunt requires at least one target to run so you can simply put 'all: {}' here too.
options: {
configFile: 'test/e2e/conf.js', // Default config file
keepAlive: false, // If false, the grunt process stops when the test fails.
noColor: false // If true, protractor will not use colors in its output.
}
}
},
uglify: {
dist: {
options: {
preserveComments: 'all'
},
files: {
'dist/osel-search.min.js': ['dist/osel-search.js']
}
}
}
});
grunt.registerTask('default', function () {
grunt.log.writeln('grunt dist to package code for a release');
grunt.log.writeln('grunt dev to watch src then rebuild js/css/templates automatically');
});
grunt.registerTask('sauce-connect', 'Launch Sauce Connect', function () {
var done = this.async();
require('sauce-connect-launcher')({
username: process.env.SAUCE_USERNAME,
accessKey: process.env.SAUCE_ACCESS_KEY
}, function (err, sauceConnectProcess) {
if (err) {
console.error(err.message);
} else {
console.log('sauce-connect tunnel opened successfully');
done();
}
});
});
grunt.registerTask('dist', ['jshint:all', 'concat:dist', 'uglify:dist', 'ngtemplates:dist', 'less:dist']);
grunt.registerTask('dev', ['dist', 'concurrent:dev']);
grunt.registerTask('test', ['connect:server', 'sauce-connect', 'protractor:all']);
return grunt;
};