Skip to content

Improve XML parser validation output #1287

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 1, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/services/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as helpers from "../common/helpers";
import * as semver from "semver";
import * as minimatch from "minimatch";
import Future = require("fibers/future");
import {EOL} from "os";

export class PlatformService implements IPlatformService {
private static TNS_MODULES_FOLDER_NAME = "tns_modules";
Expand Down Expand Up @@ -179,15 +180,20 @@ export class PlatformService implements IPlatformService {
.forEach(file => {
let fileContents = this.$fs.readText(file).wait();
let hasErrors = false;
let domErrorHandler = (level:any, msg:string) => hasErrors = true;
let errorOutput = "";
let domErrorHandler = (level:any, msg:string) => {
errorOutput += level + EOL + msg + EOL;
hasErrors = true;
};
let parser = new DomParser({
locator:{},
errorHandler: domErrorHandler
});
parser.parseFromString(fileContents, "text/xml");
xmlHasErrors = xmlHasErrors || hasErrors;
if (xmlHasErrors) {
this.$logger.out("Error: ".red.bold + file + " has syntax errors.".red.bold);
this.$logger.warn(`${file} has syntax errors.`);
this.$logger.out(errorOutput);
}
});
return !xmlHasErrors;
Expand Down