Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-order return value properties #801

Merged
merged 1 commit into from
Feb 8, 2024
Merged

Re-order return value properties #801

merged 1 commit into from
Feb 8, 2024

Conversation

ehmicky
Copy link
Collaborator

@ehmicky ehmicky commented Feb 7, 2024

This re-orders the properties of the Execa return value (on success or error). When the result is printed, that order is preserved, so this PR makes them follow a logical order.

Also, this adds a test to make sure we are not missing properties, which avoids bugs like #798.


if (all !== undefined) {
error.all = all;
}

error.stdio = stdio;

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stdout/stderr/all/stdio are potentially big, so they are put last.

@@ -84,27 +84,29 @@ export const makeError = ({
error.shortMessage = shortMessage;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error.*message is the most important, so should come first.

@@ -84,27 +84,29 @@ export const makeError = ({
error.shortMessage = shortMessage;
error.command = command;
error.escapedCommand = escapedCommand;
error.cwd = cwd;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command's request properties (command and cwd) come before the result ones (exitCode, etc.).

error.failed = true;
error.timedOut = Boolean(timedOut);
error.isCanceled = isCanceled;
error.isTerminated = signal !== undefined;
error.exitCode = exitCode;
error.signal = signal;
error.signalDescription = signalDescription;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boolean result properties like timedOut come before more descriptive ones like exitCode and signal.


This is `undefined` when the process could not be spawned or was terminated by a [signal](#signal-1).
The `cwd` of the command if provided in the [command options](#cwd-1). Otherwise it is `process.cwd()`.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-orders the documentation too.

@sindresorhus sindresorhus merged commit 72836f3 into main Feb 8, 2024
14 checks passed
@sindresorhus sindresorhus deleted the reorder-properties branch February 8, 2024 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants