File tree 4 files changed +19
-7
lines changed
4 files changed +19
-7
lines changed Original file line number Diff line number Diff line change 1
1
# Bash Language Server
2
2
3
+ ## 5.3.2
4
+
5
+ - Handle non-zero exit status when formatting using shfmt https://github.com/bash-lsp/bash-language-server/pull/1163
6
+
3
7
## 5.3.1
4
8
5
9
- Clear diagnostics when closing document https://github.com/bash-lsp/bash-language-server/pull/1135
Original file line number Diff line number Diff line change 3
3
"description" : " A language server for Bash" ,
4
4
"author" : " Mads Hartmann" ,
5
5
"license" : " MIT" ,
6
- "version" : " 5.3.1 " ,
6
+ "version" : " 5.3.2 " ,
7
7
"main" : " ./out/server.js" ,
8
8
"typings" : " ./out/server.d.ts" ,
9
9
"bin" : {
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ describe('formatter', () => {
38
38
expect ( new Formatter ( { executablePath : 'foo' } ) . canFormat ) . toBe ( true )
39
39
} )
40
40
41
- it ( 'should set canFormat to false when formatting fails ' , async ( ) => {
41
+ it ( 'should set canFormat to false when the executable cannot be found ' , async ( ) => {
42
42
const [ result , formatter ] = await getFormattingResult ( {
43
43
document : textToDoc ( '' ) ,
44
44
executablePath : 'foo' ,
@@ -54,6 +54,14 @@ describe('formatter', () => {
54
54
)
55
55
} )
56
56
57
+ it ( 'should throw when formatting fails' , async ( ) => {
58
+ expect ( async ( ) => {
59
+ await getFormattingResult ( { document : FIXTURE_DOCUMENT . PARSE_PROBLEMS } )
60
+ } ) . rejects . toThrow (
61
+ 'Shfmt: exited with status 1: <standard input>:10:1: > must be followed by a word' ,
62
+ )
63
+ } )
64
+
57
65
it ( 'should format when shfmt is present' , async ( ) => {
58
66
const [ result ] = await getFormattingResult ( { document : FIXTURE_DOCUMENT . SHFMT } )
59
67
expect ( result ) . toMatchInlineSnapshot ( `
Original file line number Diff line number Diff line change @@ -91,14 +91,10 @@ export class Formatter {
91
91
proc . stdin . end ( documentText )
92
92
} )
93
93
94
- // NOTE: do we care about exit code? 0 means "ok", 1 possibly means "errors",
95
- // but the presence of parseable errors in the output is also sufficient to
96
- // distinguish.
97
94
let exit
98
95
try {
99
96
exit = await proc
100
97
} catch ( e ) {
101
- // TODO: we could do this up front?
102
98
if ( ( e as any ) . code === 'ENOENT' ) {
103
99
// shfmt path wasn't found, don't try to format any more:
104
100
logger . warn (
@@ -107,7 +103,11 @@ export class Formatter {
107
103
this . _canFormat = false
108
104
return ''
109
105
}
110
- throw new Error ( `Shfmt: failed with code ${ exit } : ${ e } \nout:\n${ out } \nerr:\n${ err } ` )
106
+ throw new Error ( `Shfmt: child process error: ${ e } ` )
107
+ }
108
+
109
+ if ( exit != 0 ) {
110
+ throw new Error ( `Shfmt: exited with status ${ exit } : ${ err } ` )
111
111
}
112
112
113
113
return out
You can’t perform that action at this time.
0 commit comments