create.js
This file
Path
test/methods/create.js
64 lines · 3.0 KiB · JavaScript
Last changed by
TweaksSindre Sorhusbefore adoption698a1b8
History of this fileTake it
TweaksSindre Sorhusbefore adoption698a1b8
line 1why, one step back1import assert from 'node:assert/strict';Upgrade dependencies (#1138)ehmickybefore adoptionabd9fd0
line 2why, one step back2import path from 'node:path';TweaksSindre Sorhusbefore adoption698a1b8
line 3why, one step back3import test from 'node:test';Refactor logic and rename some variables (#983)ehmickybefore adoptionbd3b478
lines 4–14why, one step back4import {5 execa,6 execaSync,7 execaNode,8 $,9} from '../../index.js';10import {foobarString, foobarArray} from '../helpers/input.js';11import {setFixtureDirectory, FIXTURES_DIRECTORY} from '../helpers/fixtures-directory.js';1213setFixtureDirectory();14Upgrade dependencies (#1138)ehmickybefore adoptionabd9fd0
line 15why, one step back15const NOOP_PATH = path.join(FIXTURES_DIRECTORY, 'noop.js');Refactor logic and rename some variables (#983)ehmickybefore adoptionbd3b478
line 16why, one step back16TweaksSindre Sorhusbefore adoption698a1b8
line 17why, one step back17const testTemplate = async execaMethod => {Refactor logic and rename some variables (#983)ehmickybefore adoptionbd3b478
line 18why, one step back18 const {stdout} = await execaMethod`${NOOP_PATH} ${foobarString}`;TweaksSindre Sorhusbefore adoption698a1b8
line 19why, one step back19 assert.equal(stdout, foobarString);Refactor logic and rename some variables (#983)ehmickybefore adoptionbd3b478
lines 20–21why, one step back20};21TweaksSindre Sorhusbefore adoption698a1b8
lines 22–24why, one step back22test('execa() can use template strings', () => testTemplate(execa));23test('execaNode() can use template strings', () => testTemplate(execaNode));24test('$ can use template strings', () => testTemplate($));Refactor logic and rename some variables (#983)ehmickybefore adoptionbd3b478
line 25why, one step back25TweaksSindre Sorhusbefore adoption698a1b8
line 26why, one step back26const testTemplateSync = execaMethod => {Refactor logic and rename some variables (#983)ehmickybefore adoptionbd3b478
line 27why, one step back27 const {stdout} = execaMethod`${NOOP_PATH} ${foobarString}`;TweaksSindre Sorhusbefore adoption698a1b8
line 28why, one step back28 assert.equal(stdout, foobarString);Refactor logic and rename some variables (#983)ehmickybefore adoptionbd3b478
lines 29–30why, one step back29};30TweaksSindre Sorhusbefore adoption698a1b8
lines 31–32why, one step back31test('execaSync() can use template strings', () => testTemplateSync(execaSync));32test('$.sync can use template strings', () => testTemplateSync($.sync));Refactor logic and rename some variables (#983)ehmickybefore adoptionbd3b478
line 33why, one step back33TweaksSindre Sorhusbefore adoption698a1b8
line 34why, one step back34const testTemplateOptions = async execaMethod => {Refactor logic and rename some variables (#983)ehmickybefore adoptionbd3b478
line 35why, one step back35 const {stdout} = await execaMethod({stripFinalNewline: false})`${NOOP_PATH} ${foobarString}`;TweaksSindre Sorhusbefore adoption698a1b8
line 36why, one step back36 assert.equal(stdout, `${foobarString}\n`);Refactor logic and rename some variables (#983)ehmickybefore adoptionbd3b478
lines 37–38why, one step back37};38TweaksSindre Sorhusbefore adoption698a1b8
lines 39–41why, one step back39test('execa() can use template strings with options', () => testTemplateOptions(execa));40test('execaNode() can use template strings with options', () => testTemplateOptions(execaNode));41test('$ can use template strings with options', () => testTemplateOptions($));Refactor logic and rename some variables (#983)ehmickybefore adoptionbd3b478
line 42why, one step back42TweaksSindre Sorhusbefore adoption698a1b8
line 43why, one step back43const testTemplateOptionsSync = execaMethod => {Refactor logic and rename some variables (#983)ehmickybefore adoptionbd3b478
line 44why, one step back44 const {stdout} = execaMethod({stripFinalNewline: false})`${NOOP_PATH} ${foobarString}`;TweaksSindre Sorhusbefore adoption698a1b8
line 45why, one step back45 assert.equal(stdout, `${foobarString}\n`);Refactor logic and rename some variables (#983)ehmickybefore adoptionbd3b478
lines 46–47why, one step back46};47TweaksSindre Sorhusbefore adoption698a1b8
lines 48–49why, one step back48test('execaSync() can use template strings with options', () => testTemplateOptionsSync(execaSync));49test('$.sync can use template strings with options', () => testTemplateOptionsSync($.sync));Refactor logic and rename some variables (#983)ehmickybefore adoptionbd3b478
line 50why, one step back50TweaksSindre Sorhusbefore adoption698a1b8
line 51why, one step back51const testSpacedCommand = async (commandArguments, execaMethod) => {Refactor logic and rename some variables (#983)ehmickybefore adoptionbd3b478
lines 52–53why, one step back52 const {stdout} = await execaMethod('command with space.js', commandArguments);53 const expectedStdout = commandArguments === undefined ? '' : commandArguments.join('\n');TweaksSindre Sorhusbefore adoption698a1b8
line 54why, one step back54 assert.equal(stdout, expectedStdout);Refactor logic and rename some variables (#983)ehmickybefore adoptionbd3b478
lines 55–56why, one step back55};56TweaksSindre Sorhusbefore adoption698a1b8
lines 57–64why, one step back57test('allow commands with spaces and no array arguments', () => testSpacedCommand(undefined, execa));58test('allow commands with spaces and array arguments', () => testSpacedCommand(foobarArray, execa));59test('allow commands with spaces and no array arguments, execaSync', () => testSpacedCommand(undefined, execaSync));60test('allow commands with spaces and array arguments, execaSync', () => testSpacedCommand(foobarArray, execaSync));61test('allow commands with spaces and no array arguments, $', () => testSpacedCommand(undefined, $));62test('allow commands with spaces and array arguments, $', () => testSpacedCommand(foobarArray, $));63test('allow commands with spaces and no array arguments, $.sync', () => testSpacedCommand(undefined, $.sync));64test('allow commands with spaces and array arguments, $.sync', () => testSpacedCommand(foobarArray, $.sync));