Skip to content

Commit 3d9f25b

Browse files
Add new option to suppress output errors
1 parent 7930bbc commit 3d9f25b

3 files changed

Lines changed: 15 additions & 6 deletions

File tree

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "over-react-format-on-save",
33
"displayName": "OverReact Format on Save",
44
"description": "A Dart project formatting tool that enables formatting on file save. Attempts to use OverReact Format but defaults to dartfmt.",
5-
"version": "1.0.0",
5+
"version": "1.0.1",
66
"publisher": "Workiva",
77
"repository": "https://github.com/Workiva/vs-code-format-on-save/",
88
"engines": {
@@ -12,7 +12,7 @@
1212
"Other"
1313
],
1414
"activationEvents": [
15-
"*"
15+
"onLanguage:dart"
1616
],
1717
"main": "./out/extension.js",
1818
"contributes": {
@@ -47,6 +47,12 @@
4747
"type": "boolean",
4848
"description": "Allows the extension to scan for pubspec.yaml files that are nested somewhere in the project (defaulting to the project root) when the formatter runs.\n\nSee the extension details for more information.",
4949
"default": false
50+
},
51+
"overReact.formatOnSave.showOutputOnError": {
52+
"Title": "Show output console when error occurs in formatter",
53+
"type": "boolean",
54+
"description": "By default the extension will show the output console when an error occurs in the formatter. This can be disabled.",
55+
"default": true
5056
}
5157
}
5258
}

src/extension.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,14 @@ class RunFormatOnSave {
186186

187187
child.on('exit', (e) => {
188188
if (e === 0) {
189-
this.showStatusMessage('Formatting succeeded');
190-
}
189+
this.showStatusMessage('OverReact formatting succeeded');
190+
} else {
191+
this.showStatusMessage('OverReact formatting failed');
191192

192-
if (e !== 0) {
193-
this.channel.show(true);
193+
const shouldShowOutputOnError = this.config.get<Boolean>('showOutputOnError');
194+
if (shouldShowOutputOnError) {
195+
this.channel.show(true);
196+
}
194197
}
195198
});
196199
}

0 commit comments

Comments
 (0)