-
Notifications
You must be signed in to change notification settings - Fork 7
/
Gruntfile.js
105 lines (92 loc) · 2.46 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
var mackstar = {}
mackstar.build = {}
mackstar.build.getPhpFileFilter = function(name) {
name = name.split('Test.php')[0];
name = name.split('.php')[0];
if (name.indexOf("/") !== -1) {
dirs = name.split('/');
name = dirs[dirs.length -1];
}
return name;
}
module.exports = function(grunt) {
var env = grunt.option('env') || 'development',
name = grunt.option('name') || undefined;
grunt.initConfig({
php: {
filter: ""
},
watch: {
base: {
files: ['src/**/*.php', 'tests/**/*.php'],
tasks: ['shell:phpunit_base'],
options: {
nospawn: true
}
},
admin: {
files: ['dist/**/*'],
tasks: ['shell:copy_admin_assets'],
options: {
nospawn: true
}
},
css: {
files: ['*/**/*.less'],
tasks: ['shell:css'],
options: {
nospawn: true
}
}
},
shell: {
options: {
stdout: true
},
css: {
command: "lessc lib/less/bootstrap.less > dist/spout-admin/css/bootstrap.min.css --compress"
},
migrate: {
command: "vendor/robmorgan/phinx/bin/phinx --configuration=config.php migrate -e" + env
},
phpunit_base: {
command: "phpunit <%= php.filter %>"
},
copy_admin_assets: {
command: "cp -R dist/spout-admin/* ../../../var/www/spout-admin/"
}
},
karma: {
unit: {
configFile: 'tests/js/karma.conf.js',
reporters: ['dots']
},
ci: {
configFile: 'tests/js/karma.conf.js',
reporters: ['junit', 'dots'],
singleRun: true
},
}
});
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('migrate', function() {
grunt.task.run("shell:migrate");
});
grunt.registerTask('migrate:create', function() {
grunt.task.run("shell:migrate_create");
});
grunt.registerTask('migrate:rollback', function() {
grunt.task.run("shell:migrate_rollback");
});
grunt.event.on('watch', function(action, filepath) {
filter = mackstar.build.getPhpFileFilter(filepath);
grunt.config(['php', 'filter'], "--filter " + filter);
});
grunt.registerTask('default', ['karma']);
grunt.registerTask('js', ['karma:unit']);
grunt.registerTask('css', ['shell:css']);
grunt.registerTask('phpunit', ['shell:phpunit']);
grunt.registerTask('build', ['karma:ci']);
};