-
Notifications
You must be signed in to change notification settings - Fork 0
/
habitat.js
33 lines (26 loc) · 893 Bytes
/
habitat.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
"use strict";
var xml2js = require("xml2js");
var fs = require("fs");
var habitat = {};
habitat.getConfiguration = function getConfigFile(filename) {
var data = fs.readFileSync(filename);
var parser = new xml2js.Parser();
var content;
parser.parseString(data, function (err, result) {
if (err !== null) throw err;
content = result;
});
return content;
};
habitat.getSiteUrl = function getSiteUrl(options) {
if (!options) options = {};
var publishFile = options.publishingSettingsFile ? options.publishingSettingsFile : "./publishsettings.targets";
try {
var configuration = habitat.getConfiguration(publishFile);
return configuration.Project.PropertyGroup[0].publishUrl[0];
} catch(error) {
error.message = "Could not get the Habitat site URL from '" + publishFile + "'. Error:" + error.message;
throw(error);
}
};
module.exports = habitat;