Skip to content

Commit

Permalink
chore: fix bin tests for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
nlf committed Apr 4, 2022
1 parent 2f7c0d1 commit cdbdc5e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions test/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
const t = require('tap')
const { spawnSync } = require('child_process')

const nodePath = process.execPath
const binPath = require.resolve('../bin/index.js')

const cwd = t.testdir({
Expand All @@ -24,7 +25,7 @@ const cwd = t.testdir({
})

t.test('no args', async (t) => {
const result = spawnSync(binPath, [], { cwd, encoding: 'utf8' })
const result = spawnSync(nodePath, [binPath], { cwd, encoding: 'utf8' })
t.equal(result.status, 0, 'completed successfully')
t.same(result.stdout, [
'lib/cat.js',
Expand All @@ -39,7 +40,7 @@ t.test('no args', async (t) => {
})

t.test('--sort', async (t) => {
const result = spawnSync(binPath, ['--sort'], { cwd, encoding: 'utf8' })
const result = spawnSync(nodePath, [binPath, '--sort'], { cwd, encoding: 'utf8' })
t.equal(result.status, 0, 'completed successfully')
t.same(result.stdout, [
'index.js',
Expand All @@ -54,7 +55,7 @@ t.test('--sort', async (t) => {
})

t.test('-s', async (t) => {
const result = spawnSync(binPath, ['-s'], { cwd, encoding: 'utf8' })
const result = spawnSync(nodePath, [binPath, '-s'], { cwd, encoding: 'utf8' })
t.equal(result.status, 0, 'completed successfully')
t.same(result.stdout, [
'index.js',
Expand All @@ -69,7 +70,7 @@ t.test('-s', async (t) => {
})

t.test('dir argument', async (t) => {
const result = spawnSync(binPath, ['.'], { cwd, encoding: 'utf8' })
const result = spawnSync(nodePath, [binPath, '.'], { cwd, encoding: 'utf8' })
t.equal(result.status, 0, 'completed successfully')
t.same(result.stdout, [
'> .', // the directory name prefixed with "> "
Expand All @@ -85,7 +86,7 @@ t.test('dir argument', async (t) => {
})

t.test('-h', async (t) => {
const result = spawnSync(binPath, ['-h'], { cwd, encoding: 'utf8' })
const result = spawnSync(nodePath, [binPath, '-h'], { cwd, encoding: 'utf8' })
t.equal(result.status, 0, 'completed successfully')
t.match(result.stdout, /^usage: npm-packlist/, 'printed help')
})

0 comments on commit cdbdc5e

Please sign in to comment.