-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathGruntfile.js
78 lines (60 loc) · 2.27 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
module.exports = function(grunt) {
grunt.initConfig({
jshint: {
files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],
options: {
globals: {
jQuery: true
}
}
},
wiredep: {
task: {
// Point to the files that should be updated when
// you run `grunt wiredep`
src: [
'www-root/index.html', // .html support...
],
options: {
// See wiredep's configuration documentation for the options
// you may pass:
// https://github.com/taptapship/wiredep#configuration
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-wiredep');
grunt.registerTask('generate-pack-json', 'Generate Asset Pack', function(arg1, arg2) {
var fs = require('fs');
var questions_json_file = JSON.parse(fs.readFileSync('www-root/data/questions.json', 'utf8'));
var images_questions = [];
for(var category_index in questions_json_file.categories){
for(var index in questions_json_file.categories[category_index].questions){
var image_name = questions_json_file.categories[category_index].questions[index].image;
var itemAssetJson = {};
itemAssetJson.type = "image";
itemAssetJson.key = "image_question_"+category_index+'_'+index;
itemAssetJson.url = "assets/images_questions/"+image_name;
images_questions.push(itemAssetJson);
var answer_image = questions_json_file.categories[category_index].questions[index].answer_image;
itemAssetJson = {};
itemAssetJson.type = "image";
itemAssetJson.key = "image_answer_"+category_index+'_'+index;
itemAssetJson.url = "assets/images_questions/"+answer_image;
images_questions.push(itemAssetJson);
}
}
var jsonPack = {
images_questions:images_questions,
"meta": {
"generated": "1401380327373",
"app": "Phaser Asset Packer",
"url": "http://phaser.io",
"version": "1.0",
"copyright": "Photon Storm Ltd. 2014"
}
};
fs.writeFileSync('www-root/assets/images-pack.json', JSON.stringify(jsonPack,null,4) );
});
};