diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 7939aa8..581bb16 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,5 +1,3 @@ -const os = require('os'); - module.exports = { root: true, parser: '@typescript-eslint/parser', @@ -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', { diff --git a/src/PHPFmt.ts b/src/PHPFmt.ts index fa829d8..f833420 100644 --- a/src/PHPFmt.ts +++ b/src/PHPFmt.ts @@ -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`); } diff --git a/src/utils.ts b/src/utils.ts index a861e35..da0145e 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -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, @@ -16,7 +20,8 @@ export const exec = async ( } else { resolve({ stdout: String(stdout), - stderr: String(stderr) + stderr: String(stderr), + code: child.exitCode }); } }