-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.coffee
87 lines (77 loc) · 2.26 KB
/
Gruntfile.coffee
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
banner = '/**\n'
banner += ' * evo.js v<%= pkg.version %>\n'
banner += ' * <%= pkg.description %>\n'
banner += ' * Copyright (c) 2016 Alex Rowe <[email protected]>\n'
banner += ' * Licensed MIT\n'
banner += ' **/\n'
coffeebanner = '##\n'
coffeebanner += '# evo.js v<%= pkg.version %>\n'
coffeebanner += '# <%= pkg.description %>\n'
coffeebanner += '# Copyright (c) 2016 Alex Rowe <[email protected]>\n'
coffeebanner += '# Licensed MIT\n'
coffeebanner += '##\n'
module.exports = (grunt)->
grunt.initConfig
pkg: grunt.file.readJSON 'package.json'
watch:
concat:
tasks: ['concat', 'coffee']
files: ['src/*.coffee']
concat:
default:
options:
banner: coffeebanner
process: (src, filepath) ->
if filepath != 'src/head.coffee' && filepath != 'src/tail.coffee'
lines = []
src.split('\n').forEach (line) ->
lines.push( (if line.length > 0 then ' ' else '') + line)
src = lines.join('\n')
src[src.length-1] = '\n'if src[src.length-1] != '\n'
return src
src: [
'src/head.coffee',
'src/api.coffee',
'src/config.coffee',
'src/util.coffee',
'src/base.coffee',
'src/pool.coffee',
'src/network.coffee',
'src/cppn.coffee',
'src/feedforward.coffee',
'src/tail.coffee'
]
dest: 'evo.coffee'
banner:
options:
banner: banner
files:
'evo.min.js': 'evo.min.js'
'evo.js': 'evo.js'
coffee:
default:
files:
'evo.js': 'evo.coffee'
test:
files:
'specs/spec.js': 'specs/*.coffee'
uglify:
default:
files:
'evo.min.js': 'evo.js'
jasmine:
src: 'evo.js'
options:
specs: 'specs/*.js'
execute:
test:
src: ['examples/*.js']
grunt.loadNpmTasks('grunt-contrib-coffee')
grunt.loadNpmTasks('grunt-contrib-concat')
grunt.loadNpmTasks('grunt-contrib-uglify')
grunt.loadNpmTasks('grunt-contrib-watch')
grunt.loadNpmTasks('grunt-execute')
grunt.loadNpmTasks('grunt-contrib-jasmine')
grunt.registerTask 'test', ['coffee:test', 'jasmine'] #'execute']
grunt.registerTask 'compile', ['concat:default', 'coffee:default', 'uglify', 'concat:banner']
grunt.registerTask 'default', ['compile', 'test']