-
Notifications
You must be signed in to change notification settings - Fork 1
/
BuildManifestProcessor.js
63 lines (48 loc) · 2.21 KB
/
BuildManifestProcessor.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
var objArgs = WScript.Arguments;
for (i = 0; i < objArgs.length; i++) {
WScript.Echo("Arg :: " + objArgs(i));
}
var projectFilePath = null;
if (objArgs && objArgs.length > 0) {
projectFilePath = objArgs(0);
}
var fso = WScript.CreateObject("Scripting.FileSystemObject");
var outFile = fso.CreateTextFile("..\\..\\CordovaSourceDictionary.xml", true);
outFile.WriteLine('<?xml version="1.0" encoding="utf-8"?>');
outFile.WriteLine('<!-- This file is auto-generated, do not edit! -jm -->');
outFile.WriteLine('<CordovaSourceDictionary>');
// We need to get any Linked files from the project
WScript.Echo("Adding Source Files ...");
if (projectFilePath != null) {
var projXml = WScript.CreateObject("Microsoft.XMLDOM");
projXml.async = false;
if (projXml.load(projectFilePath)) {
// add linked content ( windows shortcuts )
var nodes = projXml.selectNodes("/Project/ItemGroup/Content/Link");
WScript.Echo("/Project/ItemGroup/Content/Link nodes.length" + nodes.length);
for (var n = 0; n < nodes.length; n++) {
outFile.WriteLine(' <FilePath Value="' + nodes[n].text + '"/>');
}
// add files of type Resource
nodes = projXml.selectNodes("/Project/ItemGroup/Resource/Link");
WScript.Echo("/Project/ItemGroup/Resource/Link nodes.length" + nodes.length);
for (n = 0; n < nodes.length; n++) {
outFile.WriteLine(' <FilePath Value="' + nodes[n].text + '"/>');
}
// add Content files from www folder
nodes = projXml.selectNodes("/Project/ItemGroup/Content[@Include]");
WScript.Echo("/Project/ItemGroup/Content nodes.length" + nodes.length);
for (n = 0; n < nodes.length; n++) {
for (var i = 0; i < nodes[n].attributes.length; i++) {
if (nodes[n].attributes[i].name == "Include") {
var val = nodes[n].attributes[i].value;
if (val.indexOf("www") == 0) {
WScript.Echo("adding value :: " + val);
outFile.WriteLine(' <FilePath Value="' + val + '"/>');
}
}
}
}
}
}
outFile.WriteLine('</CordovaSourceDictionary>');