Skip to content
Myr

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

5 files+59 added−0 removed

modified:test/command.js+5 added
235 unmodified lines
236 const {stdout} = $.sync`echo.js foo bar`;237 t.is(stdout, 'foo\nbar');238});239240test('$.sync can be called $.s', t => {241 const {stdout} = $.s`echo.js foo bar`;242 t.is(stdout, 'foo\nbar');243});244245test('$.sync accepts options', t => {246 const {stdout} = $({stripFinalNewline: true}).sync`noop.js foo`;247 t.is(stdout, 'foo');248});
92 unmodified lines
modified:index.d.ts+50 added
850 unmodified lines
851 sync(852 templates: TemplateStringsArray,853 ...expressions: TemplateExpression[]854 ): ExecaSyncReturnValue<StdoutStderrType>;855856 /**857 Same as $\`command\` but synchronous.858859 @returns A `childProcessResult` object860 @throws A `childProcessResult` error861862 @example <caption>Basic</caption>863 ```864 import {$} from 'execa';865866 const branch = $.s`git branch --show-current`;867 $.s`dep deploy --branch=${branch}`;868 ```869870 @example <caption>Multiple arguments</caption>871 ```872 import {$} from 'execa';873874 const args = ['unicorns', '&', 'rainbows!'];875 const {stdout} = $.s`echo ${args}`;876 console.log(stdout);877 //=> 'unicorns & rainbows!'878 ```879880 @example <caption>With options</caption>881 ```882 import {$} from 'execa';883884 $.s({stdio: 'inherit'})`echo unicorns`;885 //=> 'unicorns'886 ```887888 @example <caption>Shared options</caption>889 ```890 import {$} from 'execa';891892 const $$ = $({stdio: 'inherit'});893894 $$.s`echo unicorns`;895 //=> 'unicorns'896897 $$.s`echo rainbows`;898 //=> 'rainbows'899 ```900 */901 s(902 templates: TemplateStringsArray,903 ...expressions: TemplateExpression[]904 ): ExecaSyncReturnValue<StdoutStderrType>;905};906907/**908Executes a command. The `command` string includes both the `file` and its `arguments`. Returns a `childProcess`.
87 unmodified lines
modified:index.js+2 added
261 unmodified lines
262 const [file, ...args] = parseTemplates(templates, expressions);263 return execaSync(file, args, normalizeScriptOptions(options));264 };265266 $.s = $.sync;267268 return $;269}270271export const $ = create$();
42 unmodified lines
modified:index.test-d.ts+1 added
290 unmodified lines
291292expectType<ExecaChildProcess>($`unicorns`);293expectType<ExecaReturnValue>(await $`unicorns`);294expectType<ExecaSyncReturnValue>($.sync`unicorns`);295expectType<ExecaSyncReturnValue>($.s`unicorns`);296297expectType<ExecaChildProcess>($({encoding: 'utf8'})`unicorns`);298expectType<ExecaReturnValue>(await $({encoding: 'utf8'})`unicorns`);299expectType<ExecaSyncReturnValue>($({encoding: 'utf8'}).sync`unicorns`);
48 unmodified lines
modified:readme.md+1 added
290 unmodified lines
291292Returns or throws a [`childProcessResult`](#childProcessResult).293294### $.sync\`command\`295### $.s\`command\`296297Same as [$\`command\`](#command) but synchronous.298299Returns or throws a [`childProcessResult`](#childProcessResult).
512 unmodified lines