Skip to content

Commit

Permalink
chore: manually create/delete node.exe in shim test
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed Sep 11, 2023
1 parent 0d9821c commit 6ec6ff0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions test/bin/windows-shims.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
const t = require('tap')
const { spawnSync } = require('child_process')
const { resolve, join, extname, basename, sep } = require('path')
const { readFileSync, chmodSync, readdirSync, rmSync } = require('fs')
const { copyFileSync, readFileSync, chmodSync, readdirSync, rmSync } = require('fs')
const Diff = require('diff')
const { sync: which } = require('which')
const { version } = require('../../package.json')

const ROOT = resolve(__dirname, '../..')
const BIN = join(ROOT, 'bin')
const NODE = readFileSync(process.execPath)
const SHIMS = readdirSync(BIN).reduce((acc, shim) => {
if (extname(shim) !== '.js') {
acc[shim] = readFileSync(join(BIN, shim), 'utf-8')
Expand Down Expand Up @@ -67,7 +66,6 @@ t.test('shim contents', t => {
t.test('run shims', t => {
const path = t.testdir({
...SHIMS,
'node.exe': NODE,
// simulate the state where one version of npm is installed
// with node, but we should load the globally installed one
'global-prefix': {
Expand All @@ -94,7 +92,13 @@ t.test('run shims', t => {

// hacky fix to decrease flakes of this test from `NOTEMPTY: directory not empty, rmdir`
// this should get better in tap@18 and we can try removing it then
t.teardown(() => rmSync(path, { recursive: true, force: true }))
copyFileSync(process.execPath, join(path, 'node.exe'))
t.teardown(async () => {
rmSync(join(path, 'node.exe'))
await new Promise(res => setTimeout(res, 100))
// this is superstition

This comment has been minimized.

Copy link
@isaacs

isaacs Sep 16, 2023

Contributor

😂

rmSync(join(path, 'node.exe'), { force: true })
})

const spawnPath = (cmd, args, { log, stdioString = true, ...opts } = {}) => {
if (cmd.endsWith('bash.exe')) {
Expand Down

0 comments on commit 6ec6ff0

Please sign in to comment.