forked from AlexDisler/cordova-splash
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathios_cordova_contents_override.js
More file actions
48 lines (40 loc) · 1.1 KB
/
ios_cordova_contents_override.js
File metadata and controls
48 lines (40 loc) · 1.1 KB
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
var fs = require("fs-extra");
var Q = require("q");
var display = require("./display");
var scales = ["1x", "2x", "3x"];
function getPath(projectName) {
return (
"platforms/ios/" +
projectName +
"/Images.xcassets/LaunchStoryboard.imageset/Contents.json"
);
}
function updateContentsJson(projectName) {
var deferred = Q.defer();
var path = getPath(projectName);
fs.readJson(path, function (err, contents) {
if (err) {
display.error("error during Contents.json for iOS update");
deferred.reject(err);
return;
}
contents.images = scales.map(function (scale) {
return {
scale: scale,
idiom: "universal",
filename: "Default@" + scale + "~universal.png",
};
});
fs.writeJson(path, contents, { spaces: 2 }, function (err) {
if (err) {
display.error("error during Contents.json for iOS update");
deferred.reject(err);
return;
}
display.success("updated Contents.json for iOS");
deferred.resolve();
});
});
return deferred.promise;
}
module.exports = updateContentsJson;