File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -249,7 +249,7 @@ if (argv["help"] || (!filepatterns.length && !stdin)) {
249249 " --trailing-comma <none|es5|all>\n" +
250250 " Print trailing commas wherever possible. Defaults to none.\n" +
251251 " --parser <flow|babylon> Specify which parse to use. Defaults to babylon.\n" +
252- " --cursor-offset <int> Instead of formatting the code, print where a cursor at the given position would move to after formatting.\n" +
252+ " --cursor-offset <int> Print (to stderr) where a cursor at the given position would move to after formatting.\n" +
253253 " This option cannot be used with --range-start and --range-end\n" +
254254 " --range-start <int> Format code starting at a given character offset.\n" +
255255 " The range will extend backwards to the start of the first line containing the selected statement.\n" +
@@ -364,11 +364,11 @@ if (stdin) {
364364}
365365
366366function writeOutput ( result ) {
367+ // Don't use `console.log` here since it adds an extra newline at the end.
368+ process . stdout . write ( result . formatted ) ;
369+
367370 if ( options . cursorOffset ) {
368- console . log ( result . cursorOffset ) ;
369- } else {
370- // Don't use `console.log` here since it adds an extra newline at the end.
371- process . stdout . write ( result . formatted ) ;
371+ process . stderr . write ( result . cursorOffset + "\n" ) ;
372372 }
373373}
374374
You can’t perform that action at this time.
0 commit comments