Skip to content
Open
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
24 changes: 9 additions & 15 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class PHPCBF {
if (!config.get("enable") === true) {
return;
}

this.log = vscode.window.createOutputChannel('phpcbf');

this.onsave = config.get("onsave", false);

this.executablePath = config.get(
Expand Down Expand Up @@ -70,18 +73,14 @@ class PHPCBF {
args.push("--standard=" + this.standard);
}
if (this.debug) {
console.group("PHPCBF");
console.log(
this.log.appendLine(
"PHPCBF args: " + this.executablePath + " " + args.join(" ")
);
}
return args;
}

format(text) {
if (this.debug) {
console.time("phpcbf");
}
let phpcbfError = false;
let fileName =
TmpDir +
Expand All @@ -101,7 +100,7 @@ class PHPCBF {
let promise = new Promise((resolve, reject) => {
exec.on("error", err => {
reject();
console.log(err);
this.log.appendLine(err);
if (err.code == "ENOENT") {
window.showErrorMessage(
"PHPCBF: " + err.message + ". executablePath not found."
Expand Down Expand Up @@ -148,24 +147,19 @@ class PHPCBF {

if (phpcbfError) {
exec.stdout.on("data", buffer => {
console.log(buffer.toString());
this.log.appendLine(buffer.toString());
window.showErrorMessage(buffer.toString());
});
}
if (this.debug) {
exec.stdout.on("data", buffer => {
console.log(buffer.toString());
this.log.appendLine(buffer.toString());
});
}
exec.stderr.on("data", buffer => {
console.log(buffer.toString());
this.log.appendLine(buffer.toString());
});
exec.on("close", code => {
// console.log(code);
if (this.debug) {
console.timeEnd("phpcbf");
console.groupEnd();
}
});

return promise;
Expand Down Expand Up @@ -258,7 +252,7 @@ exports.activate = context => {
}
})
.catch(err => {
console.log(err);
this.log.appendLine(err);
reject();
});
});
Expand Down