Skip to content

Commit

Permalink
log source when iOS source error
Browse files Browse the repository at this point in the history
  • Loading branch information
meowtec committed Sep 19, 2016
1 parent 4e096af commit 6f8c6a7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
22 changes: 21 additions & 1 deletion lib/ios.js
Expand Up @@ -5,9 +5,21 @@ const path = require('path');
const logger = require('./common/logger');
const XCTest = require('xctest-client');
const Simulator = require('ios-simulator');
const pkg = require('../package.json');
const chalk = require('chalk');

This comment has been minimized.

Copy link
@xudafeng

xudafeng Sep 19, 2016

Member

这里顺序不对,跟其他风格不统一


const _ = require('./common/helper');

function reportNodesError(source) {
return chalk.red(
`The source may be wrong, please report with below message at:
${chalk.blue(pkg.bugs)}
****** xctest source start *******
${JSON.stringify(JSON.parse(source))}
'****** xctest source end *******`
);
}

const adaptor = function(node) {
node.class = node.type;

Expand Down Expand Up @@ -44,8 +56,16 @@ exports.dumpXMLAndScreenShot = function *() {
_.mkdir(tempDir);
const xmlFilePath = path.join(tempDir, 'ios.json');

let compatibleTree;
try {
compatibleTree = adaptor(tree);
} catch(e) {
console.error(reportNodesError(source));
throw e;
}

fs.writeFileSync(xmlFilePath, JSON.stringify(compatibleTree), 'utf8');
logger.debug(`Dump iOS XML success, save to ${xmlFilePath}`);
fs.writeFileSync(xmlFilePath, JSON.stringify(adaptor(tree)), 'utf8');

const screenshot = yield _.request(`http://${xctest.proxyHost}:${xctest.proxyPort}/screenshot`, 'get', {});
const base64Data = JSON.parse(screenshot).value;
Expand Down
3 changes: 2 additions & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "app-inspector",
"version": "1.2.8",
"version": "1.2.9",
"description": "app inspector",
"keywords": [
"inspector",
Expand Down Expand Up @@ -64,6 +64,7 @@
"jshint"
],
"homepage": "https://github.com/macacajs/app-inspector",
"bugs": "https://github.com/macacajs/app-inspector/issues/new",
"license": "MIT",
"optionalDependencies": {
"ios-simulator": "^1.0.7",
Expand Down

0 comments on commit 6f8c6a7

Please sign in to comment.