Skip to content

Commit

Permalink
Test global binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Aug 18, 2024
1 parent 547ab21 commit 2b57480
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import process from 'node:process';
import {setTimeout} from 'node:timers/promises';
import test from 'ava';
import nanoSpawn from './index.js';

const isWindows = process.platform === 'win32';

// TODO: replace with Array.fromAsync() after dropping support for Node <22.0.0
const arrayFromAsync = async asyncIterable => {
const chunks = [];
Expand Down Expand Up @@ -187,3 +190,13 @@ test('Handles stderr error', async t => {
promise.subprocess.stderr.emit('error', error);
t.is(await t.throwsAsync(promise), error);
});

test('Can run global npm binaries', async t => {
const {stdout} = await nanoSpawn('npm', ['--version'], {shell: isWindows});
t.regex(stdout, /^\d+\.\d+\.\d+/);
});

test('Can run OS binaries', async t => {
const {stdout} = await nanoSpawn('git', ['--version']);
t.regex(stdout, /^git version \d+\.\d+\.\d+/);
});

0 comments on commit 2b57480

Please sign in to comment.