-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgruntfile.coffee
94 lines (83 loc) · 3.73 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
88
89
90
91
92
93
94
module.exports = (grunt) ->
require('time-grunt')(grunt)
endOfLine = require('os').EOL
require('load-grunt-config') grunt,
jitGrunt:
staticMappings:
lyriaData: 'grunt-lyria-assets'
lyriaAssetList: 'grunt-lyria-assets'
lyriaScene: 'grunt-lyria-assets'
releaseBranch: 'grunt-release-branch'
preReleaseBranch: 'grunt-release-branch'
grunt.registerTask 'prebuild', 'Task before building the project', ['lyriaScene', 'lyriaAssetList', 'lyriaData',
'amd_tamer:dist']
grunt.registerTask 'lint', 'Lints JavaScript and CSS files', ['jshint']
grunt.registerTask 'development', 'Development build', ['clean:build', 'csvToJson', 'prebuild', 'copy:assets',
'copy:root',
'bowercopy',
'stylus:development', 'amd_tamer:all',
'clean:build_debug_js',
'consolidate:development']
grunt.registerTask 'production', 'Production build', ['development', 'copy:production', 'uglify',
'stylus:production', 'consolidate:production']
grunt.registerTask 'pack', 'Packs project', ['production', 'compress']
grunt.registerTask 'deploy', 'Builds project in production mode and deploys to Github Pages', ['clean:gh_pages',
'production',
'gh-pages']
grunt.registerTask 'build', 'Builds the default project', ['development']
grunt.registerTask 'test', ['lint']
# The future in order
grunt.registerTask 'observe', ['development', 'watch']
grunt.registerTask 'default', 'Default task', ['concurrent']
`grunt.registerTask('csvToJson', 'move dialogs from csv to json', function() {
var csvFile = grunt.file.read('dialogs.csv');
var csvLines = csvFile.split(endOfLine);
var files = {};
csvLines.forEach(function(line) {
var cells = line.split(',"');
var text;
// if no cells could be found, that means, that the string isnt escaped
if (!cells[1]) {
cells = line.split(',');
cells[2] = cells[3];
} else {
cells = [cells[0]].concat(cells[1].split('",,'));
}
var code = cells[0].substr(2);
if (code === '') {
return;
}
// remove ending double quotes
var text = cells[1];
var emotion = cells[2];
var currentName = cells[0][1];
if (!files[currentName]) {
files[currentName] = {
'Bark': {},
'Meryl': {},
'Armoise': {}
};
}
if (emotion) {
text = {
text: text,
emotion: emotion
}
}
switch (cells[0][0]) {
case 'D':
files[currentName].Bark[code] = text;
break;
case 'M':
files[currentName].Meryl[code] = text;
break;
case 'A':
files[currentName].Armoise[code] = text;
break;
}
});
Object.keys(files).forEach(function(key) {
// write last element to a json file
grunt.file.write('assets/data/dialog/' + key + '.json', JSON.stringify(files[key], ' '));
});
});`