Skip to content

Commit

Permalink
Rename .cmd to .command (#194)
Browse files Browse the repository at this point in the history
Fixes #190
  • Loading branch information
Satya Rohith authored and sindresorhus committed Mar 25, 2019
1 parent f2cb86f commit 95c8a14
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions index.d.ts
Expand Up @@ -221,7 +221,7 @@ export interface ExecaReturnBase<StdoutStderrType> {
/**
The command that was run.
*/
cmd: string;
command: string;

/**
Whether the process timed out.
Expand Down Expand Up @@ -419,7 +419,7 @@ declare const execa: {
// stderr: '',
// all: '',
// failed: true,
// cmd: 'exit 3',
// command: 'exit 3',
// timedOut: false,
// killed: false
//}
Expand Down Expand Up @@ -476,7 +476,7 @@ declare const execa: {
// stdout: '',
// stderr: '',
// failed: true,
// cmd: 'exit 3',
// command: 'exit 3',
// timedOut: false
//}
}
Expand Down
6 changes: 3 additions & 3 deletions index.js
Expand Up @@ -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;

Expand Down Expand Up @@ -341,7 +341,7 @@ const execa = (command, args, options) => {
exitCodeName: 'SUCCESS',
failed: false,
killed: false,
cmd: joinedCommand,
command: joinedCommand,
timedOut: false,
isCanceled: false
};
Expand Down Expand Up @@ -422,7 +422,7 @@ module.exports.sync = (command, args, options) => {
exitCode: 0,
exitCodeName: 'SUCCESS',
failed: false,
cmd: joinedCommand,
command: joinedCommand,
timedOut: false
};
};
Expand Down
4 changes: 2 additions & 2 deletions index.test-d.ts
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Expand Up @@ -67,7 +67,7 @@ const execa = require('execa');
stderr: '',
all: '',
failed: true,
cmd: 'exit 3',
command: 'exit 3',
timedOut: false,
killed: false
}
Expand Down Expand Up @@ -101,7 +101,7 @@ try {
stdout: '',
stderr: '',
failed: true,
cmd: 'exit 3',
command: 'exit 3',
timedOut: false
}
*/
Expand Down
14 changes: 7 additions & 7 deletions test.js
Expand Up @@ -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';
Expand Down

0 comments on commit 95c8a14

Please sign in to comment.