fix tracetemplate detection logic and logging (fix #1386)

This commit is contained in:
Jonathan Lipps
2013-10-30 08:04:12 -07:00
parent 5b63fadfe8
commit 21e97dc959

View File

@@ -321,23 +321,29 @@ IOS.prototype.setXcodeVersion = function(cb) {
};
IOS.prototype.detectTraceTemplate = function(cb) {
if (this.automationTraceTemplatePath === null) {
helpers.getXcodeFolder(function(res, xcodeFolderPath) {
var msg;
if (!this.automationTraceTemplatePath) {
helpers.getXcodeFolder(function(err, xcodeFolderPath) {
if (err) return cb(err);
if (xcodeFolderPath !== null) {
var xcodeTraceTemplatePath = path.resolve(xcodeFolderPath,
"../Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/" +
"../Applications/Instruments.app/Contents/PlugIns",
"AutomationInstrument.bundle/Contents/Resources",
"Automation.tracetemplate");
if (fs.existsSync(xcodeTraceTemplatePath)) {
this.automationTraceTemplatePath = xcodeTraceTemplatePath;
cb();
} else {
logger.error("Could not find Automation.tracetemplate in " + xcodeTraceTemplatePath);
cb(new Error("Could not find Automation.tracetemplate in " + xcodeTraceTemplatePath));
msg = "Could not find Automation.tracetemplate in " +
xcodeTraceTemplatePath;
logger.error(msg);
cb(new Error(msg));
}
} else {
logger.error("Could not find Automation.tracetemplate because XCode could not be found. " +
"Try setting the path with xcode-select.");
cb(new Error("Could not find Automation.tracetemplate because XCode could not be found."));
msg = "Could not find Automation.tracetemplate because XCode " +
"could not be found. Try setting the path with xcode-select.";
logger.error(msg);
cb(new Error(msg));
}
}.bind(this));
} else {