-
Notifications
You must be signed in to change notification settings - Fork 11
/
manifest.js
58 lines (46 loc) · 1.33 KB
/
manifest.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
var fs = require('fs');
var path = require('path');
var mustache = require('mustache');
var util = require('util')
module.exports = {
generate : function (app, output) {
return generateManifest(app, output);
},
render: function(input, basePath) {
return renderManifest(input, basePath)
}
}
function generateManifest(app, output) {
return new Promise(function(resolve, reject) {
var filepath = path.join(__dirname, 'templates', 'template.plist');
fs.readFile(filepath, function(err, data) {
if (err) {reject(err)};
var template = data.toString();
var rendered = mustache.render(template, {
name: app['name'],
bundleID: app['bundleId'],
path: util.format('{{{basePath}}}/%s', app['package']),
version: app['version'],
});
var buffer = new Buffer(rendered);
fs.writeFile(output, buffer, function(err){
if(err) {
reject(err);
}
resolve(output);
});
});
})
}
function renderManifest(input, basePath) {
return new Promise(function(resolve, reject) {
fs.readFile(input, function(err, data) {
if (err) {reject(err)};
var template = data.toString();
var rendered = mustache.render(template, {
basePath: basePath + 'app'
});
resolve(rendered);
});
})
}