Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ If planned renames clash, the process is halted and no change is applied to any
| | **`--tail`** Shorthand for setting both --name-delimiter-tail and --content-delimiter-tail. Use --no-tail to not print the delimiter after the last name and the last content. The specific tail flags win over --tail. [boolean] |
| | **`--nl`** Let what is printed to stdout and stderr (the names, or the content from -o, -m or piped data) always end with a new line. No extra new line if it already ends with a new line, or if nothing was printed. [boolean] |
| `-H` | **`--halt`**, **`--bail`** Halt on first error [boolean] [default: false] |
| `-c` | **`--status-compact`** As the last thing before ending any execution a status report will be printed as one line of JSON. Will print even in combination with `--quiet-total`. Will incude extra info about the inner workings of the engine in combination with the `--verbose` flag. [boolean] |
| | **`--status`** Same as `--status-compact`, but always starting with a `\n` followed by pretty printed JSON. [boolean] |
| `-c` | **`--status-compact`** As the last thing before ending any execution a status report will be printed as one line of JSON. Will print even in combination with `--quiet-total`. Will include extra info about the inner workings of the engine in combination with the `--verbose` flag. [boolean] |
| | **`--status`** Same as `--status-compact`, but always starting with a `\n` followed by pretty printed JSON. `--status-compact` wins when both are given. [boolean] |
| `-d` | **`--debug`** Print only the status report, with what went into the engine and what it did. Does not block the output of --output and --output-match. [boolean] |

| `-€` | **`--void-euro`** Void having `€` as alias for `$`. The alias is used in all inputs, but never in globs, file names or piped data. [boolean] |
Expand Down
11 changes: 6 additions & 5 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,13 +515,13 @@ Z z
.alias('c', 'status-compact')
.describe(
'c',
'As the last thing before ending any execution a status report will be printed as one line of JSON. Will print even in combination with `--quiet-total`. Will incude extra info about the inner workings of the engine in combination with the `--verbose` flag.'
'As the last thing before ending any execution a status report will be printed as one line of JSON. Will print even in combination with `--quiet-total`. Will include extra info about the inner workings of the engine in combination with the `--verbose` flag.'
)

.boolean('status')
.describe(
'status',
'Same as `--status-compact`, but always starting with a `\\n` followed by pretty printed JSON.'
'Same as `--status-compact`, but always starting with a `\\n` followed by pretty printed JSON. `--status-compact` wins when both are given.'
)

.boolean('d')
Expand All @@ -539,11 +539,12 @@ Z z

// The engine resolves with the status of the run, or throws a panic when the run can not go on.
// The CLI is the only part that acts on the process.
// Compact wins when both are given, as asking for it is asking for less output
function printStatus(config, status) {
if (config.status) {
writeTo(process.stdout, '\n' + JSON.stringify(status, null, 2) + '\n');
} else if (config.statusCompact) {
if (config.statusCompact) {
writeTo(process.stdout, JSON.stringify(status) + '\n');
} else if (config.status) {
writeTo(process.stdout, '\n' + JSON.stringify(status, null, 2) + '\n');
}
}

Expand Down
8 changes: 8 additions & 0 deletions test/fix/742.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,14 @@ describe('#742 the CLI', () => {
}
);

test('prints the status report on one line when both --status and --status-compact are given', async () => {
fs.writeFileSync('a.file', 'foo');
const result = await sh($`bun ${cli} o x a.file --status --status-compact --quiet-total`);
expect(result.out).toBe(
'{"files":{"searched":["a.file"],"updated":["a.file"]},"pipe":null,"warnings":[],"errors":[]}\n'
);
});

test('sets the exit code to 2 when a file gives an error, and prints the status report', async () => {
fs.writeFileSync('a.file', 'foo');
fs.chmodSync('a.file', 0);
Expand Down
Loading