Skip to content

Commit acbb37d

Browse files
committed
fix: detailed error logs
1 parent adb0049 commit acbb37d

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "php-ecs-formatter",
33
"displayName": "PHP ECS Formatter",
44
"description": "Format, fix, and compare your PHP code using Easy Coding Standard (ECS) directly in Visual Studio Code",
5-
"version": "0.3.0",
5+
"version": "0.4.0",
66
"author": {
77
"name": "Cezary Marcinik",
88
"email": "cezary.marcinik@o2.pl"

src/core/ProcessRunner.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,17 @@ export class DefaultProcessRunner implements ProcessRunner {
2626
"--fix",
2727
`--config=${configPath}`,
2828
"--no-progress-bar",
29-
"--quiet",
3029
],
3130
{ cwd: workspaceRoot }
3231
);
3332

33+
let stdoutData = "";
3434
let stderrData = "";
3535

36+
processHandle.stdout.on("data", (data) => {
37+
stdoutData += data.toString();
38+
});
39+
3640
processHandle.stderr.on("data", (data) => {
3741
stderrData += data.toString();
3842
});
@@ -45,7 +49,13 @@ export class DefaultProcessRunner implements ProcessRunner {
4549
if (code === 0) {
4650
resolve();
4751
} else {
48-
reject(new Error(`ECS exited with code ${code}\n${stderrData}`));
52+
reject(
53+
new Error(
54+
`ECS exited with code ${code}\n` +
55+
`STDERR:\n${stderrData}\n` +
56+
`STDOUT:\n${stdoutData}`
57+
)
58+
);
4959
}
5060
});
5161
});

src/test/unit/core/ProcessRunner.test.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ suite("DefaultProcessRunner", () => {
4747
"--fix",
4848
"--config=/path/to/ecs.php",
4949
"--no-progress-bar",
50-
"--quiet",
5150
],
5251
"Should pass correct arguments to ECS"
5352
);
@@ -88,21 +87,25 @@ suite("DefaultProcessRunner", () => {
8887
};
8988
spawnStub.returns(fakeChildProcess);
9089

91-
fakeChildProcess.on.withArgs("close").yields(1);
92-
90+
fakeChildProcess.stdout.on
91+
.withArgs("data")
92+
.callsArgWith(1, Buffer.from("Some ECS output"));
9393
fakeChildProcess.stderr.on
9494
.withArgs("data")
95-
.callsArgWith(1, "Some ECS error");
95+
.callsArgWith(1, Buffer.from("Some ECS error"));
96+
97+
fakeChildProcess.on.withArgs("close").yields(1);
9698

9799
const runner = new DefaultProcessRunner();
100+
98101
await assert.rejects(
99102
runner.runEcsCheck(
100103
"/path/to/ecs",
101104
"/path/to/ecs.php",
102105
"file.php",
103106
"/my/ws"
104107
),
105-
/ECS exited with code 1\nSome ECS error/
108+
/ECS exited with code 1\nSTDERR:\nSome ECS error\nSTDOUT:\nSome ECS output/
106109
);
107110
});
108111

0 commit comments

Comments
 (0)