Skip to content

Commit

Permalink
chore: simplify foregroundScripts test
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar committed Oct 5, 2022
1 parent 9e3a823 commit 9f8e3f0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
1 change: 1 addition & 0 deletions workspaces/libnpmpack/test/fixtures/tspawk.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const spawk = require('spawk')
module.exports = tspawk

function tspawk (t) {
spawk.preventUnmatched()
t.teardown(function () {
spawk.unload()
})
Expand Down
7 changes: 2 additions & 5 deletions workspaces/libnpmpack/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
const t = require('tap')

const tspawk = require('./fixtures/tspawk.js')
const spawk = tspawk(t)

const fs = require('fs')
const path = require('path')
const pack = require('../lib/index.js')
const tnock = require('./fixtures/tnock.js')
const { load: loadMockNpm } = require('../../../test/fixtures/mock-npm.js')

const OPTS = {
registry: 'https://mock.reg/',
Expand Down Expand Up @@ -140,15 +138,14 @@ t.test('packs from registry spec', async t => {
})

t.test('runs scripts in foreground when foregroundScripts === true', async t => {
const { npm } = await loadMockNpm(t, {})
const spawk = tspawk(t)

const testDir = t.testdir({
'package.json': JSON.stringify({
name: 'my-cool-pkg',
version: '1.0.0',
scripts: {
prepack: 'touch prepack',
postpack: 'touch postpack',
},
}, null, 2),
})
Expand All @@ -158,7 +155,7 @@ t.test('runs scripts in foreground when foregroundScripts === true', async t =>

const [scriptShell, scriptArgs] = makeSpawnArgs({
event: 'prepack',
path: npm.prefix,
path: testDir,
cmd: 'touch prepack',
})

Expand Down

0 comments on commit 9f8e3f0

Please sign in to comment.