main-async.js
This file
Path
test/methods/main-async.js
81 lines · 3.1 KiB · JavaScript
Last changed by
TweaksSindre Sorhusbefore adoption698a1b8
History of this fileTake it
The walk stopped after 200 commits: lines older than 9f65b86 point at it.
TweaksSindre Sorhusbefore adoption698a1b8
line 1why, one step back1import assert from 'node:assert/strict';100% test coverage (#1018)ehmickybefore adoption9f65b86
line 2why, one step back2import process from 'node:process';Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf
line 3why, one step back3import {ChildProcess} from 'node:child_process';TweaksSindre Sorhusbefore adoption698a1b8
line 4why, one step back4import test from 'node:test';100% test coverage (#1018)ehmickybefore adoption9f65b86
line 5why, one step back5import {execa} from '../../index.js';Document and test Windows fixes (#1248)Sindre Sorhusbefore adoption4b0edb3
line 6why, one step back6import {setFixtureDirectory, FIXTURES_DIRECTORY} from '../helpers/fixtures-directory.js';100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 7–12why, one step back78setFixtureDirectory();910const isWindows = process.platform === 'win32';1112if (isWindows) {TweaksSindre Sorhusbefore adoption698a1b8
line 13why, one step back13 test('execa() - cmd file', async () => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 14why, one step back14 const {stdout} = await execa('hello.cmd');TweaksSindre Sorhusbefore adoption698a1b8
line 15why, one step back15 assert.equal(stdout, 'Hello World');100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 16–17why, one step back16 });17TweaksSindre Sorhusbefore adoption698a1b8
line 18why, one step back18 test('execa() - run cmd command', async () => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 19why, one step back19 const {stdout} = await execa('cmd', ['/c', 'hello.cmd']);TweaksSindre Sorhusbefore adoption698a1b8
line 20why, one step back20 assert.equal(stdout, 'Hello World');Document and test Windows fixes (#1248)Sindre Sorhusbefore adoption4b0edb3
lines 21–23why, one step back21 });2223 // A bare command name without an extension is resolved using `PATHEXT`.TweaksSindre Sorhusbefore adoption698a1b8
line 24why, one step back24 test('execa() - resolve command extension using PATHEXT', async () => {Document and test Windows fixes (#1248)Sindre Sorhusbefore adoption4b0edb3
line 25why, one step back25 const {stdout} = await execa('hello');TweaksSindre Sorhusbefore adoption698a1b8
line 26why, one step back26 assert.equal(stdout, 'Hello World');Document and test Windows fixes (#1248)Sindre Sorhusbefore adoption4b0edb3
lines 27–28why, one step back27 });28TweaksSindre Sorhusbefore adoption698a1b8
line 29why, one step back29 test('execa() - run cmd file using a relative path', async () => {Document and test Windows fixes (#1248)Sindre Sorhusbefore adoption4b0edb3
line 30why, one step back30 const {stdout} = await execa('./hello.cmd', {cwd: FIXTURES_DIRECTORY});TweaksSindre Sorhusbefore adoption698a1b8
line 31why, one step back31 assert.equal(stdout, 'Hello World');Document and test Windows fixes (#1248)Sindre Sorhusbefore adoption4b0edb3
lines 32–34why, one step back32 });3334 // The fixture's filename contains a space and it starts with a shebang.TweaksSindre Sorhusbefore adoption698a1b8
line 35why, one step back35 test('execa() - run file with a space in its path and a shebang', async () => {Document and test Windows fixes (#1248)Sindre Sorhusbefore adoption4b0edb3
line 36why, one step back36 const {stdout} = await execa('command with space.js', ['foo']);TweaksSindre Sorhusbefore adoption698a1b8
line 37why, one step back37 assert.equal(stdout, 'foo');100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 38–40why, one step back38 });39}40TweaksSindre Sorhusbefore adoption698a1b8
line 41why, one step back41test('execa() returns a promise with pid', async () => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 42why, one step back42 const subprocess = execa('noop.js', ['foo']);TweaksSindre Sorhusbefore adoption698a1b8
line 43why, one step back43 assert.equal(typeof subprocess.pid, 'number');Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf
lines 44–46why, one step back44 await subprocess;45});46TweaksSindre Sorhusbefore adoption698a1b8
line 47why, one step back47test('execa() returns a promise with nodeChildProcess', async () => {Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf
line 48why, one step back48 const subprocess = execa('noop.js', ['foo']);TweaksSindre Sorhusbefore adoption698a1b8
lines 49–68why, one step back49 assert.ok(subprocess instanceof Promise);50 assert.ok(!(subprocess instanceof ChildProcess));51 assert.ok(subprocess.nodeChildProcess instanceof ChildProcess);52 assert.equal(subprocess.pid, subprocess.nodeChildProcess.pid);53 assert.equal(subprocess.stdout, subprocess.nodeChildProcess.stdout);54 assert.equal(subprocess.on, undefined);55 assert.equal(subprocess.once, undefined);56 assert.equal(subprocess.send, undefined);57 assert.equal(subprocess.ref, undefined);58 assert.equal(subprocess.unref, undefined);59 assert.equal(subprocess.disconnect, undefined);60 assert.equal(subprocess.channel, undefined);61 assert.equal(subprocess.connected, undefined);62 assert.equal(subprocess.exitCode, undefined);63 assert.equal(subprocess.signalCode, undefined);64 assert.equal(subprocess.killed, undefined);65 assert.equal(subprocess.spawnargs, undefined);66 assert.equal(subprocess.spawnfile, undefined);6768 assert.equal(subprocess[Symbol.dispose], undefined);Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf
lines 69–71why, one step back69 await subprocess;70});71TweaksSindre Sorhusbefore adoption698a1b8
line 72why, one step back72test('nodeChildProcess does not include Execa-specific APIs', async () => {Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf
line 73why, one step back73 const subprocess = execa('noop.js', ['foo'], {all: true});TweaksSindre Sorhusbefore adoption698a1b8
lines 74–79why, one step back74 assert.ok(!Object.hasOwn(subprocess.nodeChildProcess, 'all'));75 assert.equal(subprocess.nodeChildProcess.readable, undefined);76 assert.equal(subprocess.nodeChildProcess.writable, undefined);77 assert.equal(subprocess.nodeChildProcess.duplex, undefined);78 assert.equal(subprocess.nodeChildProcess.iterable, undefined);79 assert.equal(subprocess.nodeChildProcess[Symbol.asyncIterator], undefined);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 80–81why, one step back80 await subprocess;81});