Add `$.s` as an alias for `$.sync` (#594)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by ehmicky · committed by GitHub · parent 37669f1 · Browse files · 5 files·+59 added−0 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+59 added−0 removed
- tests:+5 added−0 removed
- other:+54 added−0 removed
Provenance
- Commit
b719fb0- Tree
5c474f6- Author
ehmicky <ehmicky@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
37669f1
5 files changed+59 added−0 removed
modified:test/command.js+5 added
235 unmodified lines236 const {stdout} = $.sync`echo.js foo bar`;237 t.is(stdout, 'foo\nbar');238 });239 240+test('$.sync can be called $.s', t => {241+ const {stdout} = $.s`echo.js foo bar`;242+ t.is(stdout, 'foo\nbar');243+});244+245 test('$.sync accepts options', t => {246 const {stdout} = $({stripFinalNewline: true}).sync`noop.js foo`;247 t.is(stdout, 'foo');248 });92 unmodified linesmodified:index.d.ts+50 added
850 unmodified lines851 sync(852 templates: TemplateStringsArray,853 ...expressions: TemplateExpression[]854 ): ExecaSyncReturnValue<StdoutStderrType>;855+856+ /**857+ Same as $\`command\` but synchronous.858+859+ @returns A `childProcessResult` object860+ @throws A `childProcessResult` error861+862+ @example <caption>Basic</caption>863+ ```864+ import {$} from 'execa';865+866+ const branch = $.s`git branch --show-current`;867+ $.s`dep deploy --branch=${branch}`;868+ ```869+870+ @example <caption>Multiple arguments</caption>871+ ```872+ import {$} from 'execa';873+874+ const args = ['unicorns', '&', 'rainbows!'];875+ const {stdout} = $.s`echo ${args}`;876+ console.log(stdout);877+ //=> 'unicorns & rainbows!'878+ ```879+880+ @example <caption>With options</caption>881+ ```882+ import {$} from 'execa';883+884+ $.s({stdio: 'inherit'})`echo unicorns`;885+ //=> 'unicorns'886+ ```887+888+ @example <caption>Shared options</caption>889+ ```890+ import {$} from 'execa';891+892+ const $$ = $({stdio: 'inherit'});893+894+ $$.s`echo unicorns`;895+ //=> 'unicorns'896+897+ $$.s`echo rainbows`;898+ //=> 'rainbows'899+ ```900+ */901+ s(902+ templates: TemplateStringsArray,903+ ...expressions: TemplateExpression[]904+ ): ExecaSyncReturnValue<StdoutStderrType>;905 };906 907 /**908 Executes a command. The `command` string includes both the `file` and its `arguments`. Returns a `childProcess`.87 unmodified linesmodified:index.js+2 added
261 unmodified lines262 const [file, ...args] = parseTemplates(templates, expressions);263 return execaSync(file, args, normalizeScriptOptions(options));264 };265 266+ $.s = $.sync;267+268 return $;269 }270 271 export const $ = create$();42 unmodified linesmodified:index.test-d.ts+1 added
290 unmodified lines291 292 expectType<ExecaChildProcess>($`unicorns`);293 expectType<ExecaReturnValue>(await $`unicorns`);294 expectType<ExecaSyncReturnValue>($.sync`unicorns`);295+expectType<ExecaSyncReturnValue>($.s`unicorns`);296 297 expectType<ExecaChildProcess>($({encoding: 'utf8'})`unicorns`);298 expectType<ExecaReturnValue>(await $({encoding: 'utf8'})`unicorns`);299 expectType<ExecaSyncReturnValue>($({encoding: 'utf8'}).sync`unicorns`);48 unmodified linesmodified:readme.md+1 added
290 unmodified lines291 292 Returns or throws a [`childProcessResult`](#childProcessResult).293 294 ### $.sync\`command\`295+### $.s\`command\`296 297 Same as [$\`command\`](#command) but synchronous.298 299 Returns or throws a [`childProcessResult`](#childProcessResult).512 unmodified lines