Repository: sindresorhus/execa (js)

Issue:
Rename `. cmd` to `.command`
In the result object and error property. Since we're doing a major release, it would be nice to make the output more readable.

Pull request:
Rename `.cmd` to `.command`
closes #190 

Patch:
diff --git a/index.d.ts b/index.d.ts
index 6f2a7b6..efab5e5 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -221,7 +221,7 @@ export interface ExecaReturnBase<StdoutStderrType> {
 	/**
 	The command that was run.
 	*/
-	cmd: string;
+	command: string;
 
 	/**
 	Whether the process timed out.
@@ -234,20 +234,20 @@ export interface ExecaReturnBase<StdoutStderrType> {
 	killed: boolean;
 }
 
-export interface ExecaSyncReturnValue<StdOutErrType = string>
-	extends ExecaReturnBase<StdOutErrType> {
+export interface ExecaSyncReturnValue<StdoutErrorType = string>
+	extends ExecaReturnBase<StdoutErrorType> {
 	/**
 	The exit code of the process that was run.
 	*/
 	code: number;
 }
 
-export interface ExecaReturnValue<StdOutErrType = string>
-	extends ExecaSyncReturnValue<StdOutErrType> {
+export interface ExecaReturnValue<StdoutErrorType = string>
+	extends ExecaSyncReturnValue<StdoutErrorType> {
 	/**
 	The output of the process with `stdout` and `stderr` interleaved.
 	*/
-	all: StdOutErrType;
+	all: StdoutErrorType;
 
 	/**
 	Whether the process was canceled.
@@ -255,9 +255,9 @@ export interface ExecaReturnValue<StdOutErrType = string>
 	isCanceled: boolean;
 }
 
-export interface ExecaSyncError<StdOutErrType = string>
+export interface ExecaSyncError<StdoutErrorType = string>
 	extends Error,
-		ExecaReturnBase<StdOutErrType> {
+		ExecaReturnBase<StdoutErrorType> {
 	/**
 	The error message.
 	*/
@@ -269,12 +269,12 @@ export interface ExecaSyncError<StdOutErrType = string>
 	code: number | string;
 }
 
-export interface ExecaError<StdOutErrType = string>
-	extends ExecaSyncError<StdOutErrType> {
+export interface ExecaError<StdoutErrorType = string>
+	extends ExecaSyncError<StdoutErrorType> {
 	/**
 	The output of the process with `stdout` and `stderr` interleaved.
 	*/
-	all: StdOutErrType;
+	all: StdoutErrorType;
 
 	/**
 	Whether the process was canceled.
@@ -282,14 +282,12 @@ export interface ExecaError<StdOutErrType = string>
 	isCanceled: boolean;
 }
 
-export interface ExecaChildPromise<StdOutErrType> {
+export interface ExecaChildPromise<StdoutErrorType> {
 	catch<ResultType = never>(
 		onRejected?:
-			| ((
-					reason: ExecaError<StdOutErrType>
-			  ) => ResultType | PromiseLike<ResultType>)
+			| ((reason: ExecaError<StdoutErrorType>) => ResultType | PromiseLike<ResultType>)
 			| null
-	): Promise<ExecaReturnValue<StdOutErrType> | ResultType>;
+	): Promise<ExecaReturnValue<StdoutErrorType> | ResultType>;
 
 	/**
 	Cancel the subprocess.
@@ -299,9 +297,9 @@ export interface ExecaChildPromise<StdOutErrType> {
 	cancel(): void;
 }
 
-export type ExecaChildProcess<StdOutErrType = string> = ChildProcess &
-	ExecaChildPromise<StdOutErrType> &
-	Promise<ExecaReturnValue<StdOutErrType>>;
+export type ExecaChildProcess<StdoutErrorType = string> = ChildProcess &
+	ExecaChildPromise<StdoutErrorType> &
+	Promise<ExecaReturnValue<StdoutErrorType>>;
 
 declare const execa: {
 	/**
@@ -421,7 +419,7 @@ declare const execa: {
 			//	stderr: '',
 			//	all: '',
 			//	failed: true,
-			//	cmd: 'exit 3',
+			//	command: 'exit 3',
 			//	timedOut: false,
 			//	killed: false
 			//}
@@ -478,7 +476,7 @@ declare const execa: {
 		//	stdout: '',
 		//	stderr: '',
 		//	failed: true,
-		//	cmd: 'exit 3',
+		//	command: 'exit 3',
 		//	timedOut: false
 		//}
 	}
diff --git a/index.js b/index.js
index 3266a07..81d0c80 100644
--- a/index.js
+++ b/index.js
@@ -164,7 +164,7 @@ function makeError(result, options) {
 	// `signal` emitted on `spawned.on('exit')` event can be `null`. We normalize
 	// it to `undefined`
 	error.signal = signal || undefined;
-	error.cmd = joinedCommand;
+	error.command = joinedCommand;
 	error.timedOut = Boolean(timedOut);
 	error.isCanceled = isCanceled;
 
@@ -341,7 +341,7 @@ const execa = (command, args, options) => {
 			exitCodeName: 'SUCCESS',
 			failed: false,
 			killed: false,
-			cmd: joinedCommand,
+			command: joinedCommand,
 			timedOut: false,
 			isCanceled: false
 		};
@@ -422,7 +422,7 @@ module.exports.sync = (command, args, options) => {
 		exitCode: 0,
 		exitCodeName: 'SUCCESS',
 		failed: false,
-		cmd: joinedCommand,
+		command: joinedCommand,
 		timedOut: false
 	};
 };
diff --git a/readme.md b/readme.md
index 53eb19c..46b5b24 100644
--- a/readme.md
+++ b/readme.md
@@ -67,7 +67,7 @@ const execa = require('execa');
 			stderr: '',
 			all: '',
 			failed: true,
-			cmd: 'exit 3',
+			command: 'exit 3',
 			timedOut: false,
 			killed: false
 		}
@@ -101,7 +101,7 @@ try {
 		stdout: '',
 		stderr: '',
 		failed: true,
-		cmd: 'exit 3',
+		command: 'exit 3',
 		timedOut: false
 	}
 	*/


Test patch:
diff --git a/index.test-d.ts b/index.test-d.ts
index 3e6eb23..12d63e9 100644
--- a/index.test-d.ts
+++ b/index.test-d.ts
@@ -12,7 +12,7 @@ try {
 	execaPromise.cancel();
 
 	const unicornsResult = await execaPromise;
-	expectType<string>(unicornsResult.cmd);
+	expectType<string>(unicornsResult.command);
 	expectType<string | number>(unicornsResult.code);
 	expectType<boolean>(unicornsResult.failed);
 	expectType<boolean>(unicornsResult.killed);
@@ -33,7 +33,7 @@ try {
 
 try {
 	const unicornsResult = execa.sync('unicorns');
-	expectType<string>(unicornsResult.cmd);
+	expectType<string>(unicornsResult.command);
 	expectType<string | number>(unicornsResult.code);
 	expectType<boolean>(unicornsResult.failed);
 	expectType<boolean>(unicornsResult.killed);
diff --git a/test.js b/test.js
index 6dfb743..eba24b6 100644
--- a/test.js
+++ b/test.js
@@ -416,19 +416,19 @@ errorMessage.title = (message, expected) => `error.message matches: ${expected}`
 test(errorMessage, /Command failed with exit code 2.*: exit 2 foo bar/, 2, 'foo', 'bar');
 test(errorMessage, /Command failed with exit code 3.*: exit 3 baz quz/, 3, 'baz', 'quz');
 
-async function cmd(t, expected, ...args) {
+async function command(t, expected, ...args) {
 	const error = await t.throwsAsync(execa('fail', args));
-	t.is(error.cmd, `fail${expected}`);
+	t.is(error.command, `fail${expected}`);
 
 	const result = await execa('noop', args);
-	t.is(result.cmd, `noop${expected}`);
+	t.is(result.command, `noop${expected}`);
 }
 
-cmd.title = (message, expected) => `cmd is: ${JSON.stringify(expected)}`;
+command.title = (message, expected) => `command is: ${JSON.stringify(expected)}`;
 
-test(cmd, ' foo bar', 'foo', 'bar');
-test(cmd, ' baz quz', 'baz', 'quz');
-test(cmd, '');
+test(command, ' foo bar', 'foo', 'bar');
+test(command, ' baz quz', 'baz', 'quz');
+test(command, '');
 
 async function spawnAndKill(t, signal, cleanup) {
 	const name = cleanup ? 'sub-process' : 'sub-process-false';