Skip to content

Commit

Permalink
fix: php version with warnings is not correct
Browse files Browse the repository at this point in the history
  • Loading branch information
kokororin committed Dec 7, 2023
1 parent 5fca11b commit 17f6b08
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
9 changes: 6 additions & 3 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const os = require('os');

module.exports = {
root: true,
parser: '@typescript-eslint/parser',
Expand All @@ -23,7 +21,12 @@ module.exports = {
'no-sync': 'error',
'prefer-promise-reject-errors': 'off',
'n/prefer-promises/fs': 'error',
'prettier/prettier': os.platform() === 'win32' ? 'off' : 'error',
'prettier/prettier': [
'error',
{
endOfLine: 'auto'
}
],
'@typescript-eslint/no-floating-promises': [
'error',
{
Expand Down
4 changes: 2 additions & 2 deletions src/PHPFmt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,11 @@ export class PHPFmt {
}

try {
const { stdout, stderr } = await exec(
const { stdout, stderr, code } = await exec(
`${this.config.php_bin} -v`,
execOptions
);
if (stderr) {
if (code !== 0) {
this.widget.logError('getting php version failed', stderr);
throw new PHPFmtError(`"php -v" returns non-zero code`);
}
Expand Down
9 changes: 7 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import https from 'https';
export const exec = async (
command: string,
options?: (ObjectEncodingOptions & ExecOptions) | undefined | null
): Promise<{ stdout: string; stderr: string }> => {
): Promise<{
stdout: string;
stderr: string;
code: number | null;
}> => {
return await new Promise((resolve, reject) => {
const child = childProcess.exec(
command,
Expand All @@ -16,7 +20,8 @@ export const exec = async (
} else {
resolve({
stdout: String(stdout),
stderr: String(stderr)
stderr: String(stderr),
code: child.exitCode
});
}
}
Expand Down

0 comments on commit 17f6b08

Please sign in to comment.