Skip to content
Myr

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 file

Take it

The walk stopped after 200 commits: lines older than 9f65b86 point at it.

TweaksSindre Sorhusbefore adoption698a1b8

line 1why, one step back
1import assert from 'node:assert/strict';

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 2why, one step back
2import process from 'node:process';

Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf

line 3why, one step back
3import {ChildProcess} from 'node:child_process';

TweaksSindre Sorhusbefore adoption698a1b8

line 4why, one step back
4import test from 'node:test';

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 5why, one step back
5import {execa} from '../../index.js';

Document and test Windows fixes (#1248)Sindre Sorhusbefore adoption4b0edb3

line 6why, one step back
6import {setFixtureDirectory, FIXTURES_DIRECTORY} from '../helpers/fixtures-directory.js';

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 7–12why, one step back
7
8setFixtureDirectory();910const isWindows = process.platform === 'win32';1112if (isWindows) {

TweaksSindre Sorhusbefore adoption698a1b8

line 13why, one step back
13 test('execa() - cmd file', async () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 14why, one step back
14 const {stdout} = await execa('hello.cmd');

TweaksSindre Sorhusbefore adoption698a1b8

line 15why, one step back
15 assert.equal(stdout, 'Hello World');

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 16–17why, one step back
16 });
17

TweaksSindre Sorhusbefore adoption698a1b8

line 18why, one step back
18 test('execa() - run cmd command', async () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 19why, one step back
19 const {stdout} = await execa('cmd', ['/c', 'hello.cmd']);

TweaksSindre Sorhusbefore adoption698a1b8

line 20why, one step back
20 assert.equal(stdout, 'Hello World');

Document and test Windows fixes (#1248)Sindre Sorhusbefore adoption4b0edb3

lines 21–23why, one step back
21 });
2223 // A bare command name without an extension is resolved using `PATHEXT`.

TweaksSindre Sorhusbefore adoption698a1b8

line 24why, one step back
24 test('execa() - resolve command extension using PATHEXT', async () => {

Document and test Windows fixes (#1248)Sindre Sorhusbefore adoption4b0edb3

line 25why, one step back
25 const {stdout} = await execa('hello');

TweaksSindre Sorhusbefore adoption698a1b8

line 26why, one step back
26 assert.equal(stdout, 'Hello World');

Document and test Windows fixes (#1248)Sindre Sorhusbefore adoption4b0edb3

lines 27–28why, one step back
27 });
28

TweaksSindre Sorhusbefore adoption698a1b8

line 29why, one step back
29 test('execa() - run cmd file using a relative path', async () => {

Document and test Windows fixes (#1248)Sindre Sorhusbefore adoption4b0edb3

line 30why, one step back
30 const {stdout} = await execa('./hello.cmd', {cwd: FIXTURES_DIRECTORY});

TweaksSindre Sorhusbefore adoption698a1b8

line 31why, one step back
31 assert.equal(stdout, 'Hello World');

Document and test Windows fixes (#1248)Sindre Sorhusbefore adoption4b0edb3

lines 32–34why, one step back
32 });
3334 // The fixture's filename contains a space and it starts with a shebang.

TweaksSindre Sorhusbefore adoption698a1b8

line 35why, one step back
35 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 back
36 const {stdout} = await execa('command with space.js', ['foo']);

TweaksSindre Sorhusbefore adoption698a1b8

line 37why, one step back
37 assert.equal(stdout, 'foo');

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 38–40why, one step back
38 });
39}40

TweaksSindre Sorhusbefore adoption698a1b8

line 41why, one step back
41test('execa() returns a promise with pid', async () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 42why, one step back
42 const subprocess = execa('noop.js', ['foo']);

TweaksSindre Sorhusbefore adoption698a1b8

line 43why, one step back
43 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 back
44 await subprocess;
45});46

TweaksSindre Sorhusbefore adoption698a1b8

line 47why, one step back
47test('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 back
48 const subprocess = execa('noop.js', ['foo']);

TweaksSindre Sorhusbefore adoption698a1b8

lines 49–68why, one step back
49 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 back
69 await subprocess;
70});71

TweaksSindre Sorhusbefore adoption698a1b8

line 72why, one step back
72test('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 back
73 const subprocess = execa('noop.js', ['foo'], {all: true});

TweaksSindre Sorhusbefore adoption698a1b8

lines 74–79why, one step back
74 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 back
80 await subprocess;
81});