diff --git a/src/lib/doctor.ts b/src/lib/doctor.ts index 04a5eb6a..60f01ab9 100644 --- a/src/lib/doctor.ts +++ b/src/lib/doctor.ts @@ -49,10 +49,10 @@ const npm = ( options.packageManager === 'pnpm' ? spawnPnpm : options.packageManager === 'yarn' - ? spawnYarn - : options.packageManager === 'bun' - ? spawnBun - : spawnNpm + ? spawnYarn + : options.packageManager === 'bun' + ? spawnBun + : spawnNpm )(args, npmOptions, spawnOptionsMerged as any) } @@ -94,10 +94,10 @@ const doctor = async (run: Run, options: Options): Promise => { options.packageManager === 'yarn' ? 'yarn.lock' : options.packageManager === 'pnpm' - ? 'pnpm-lock.yaml' - : options.packageManager === 'bun' - ? 'bun.lockb' - : 'package-lock.json' + ? 'pnpm-lock.yaml' + : options.packageManager === 'bun' + ? 'bun.lockb' + : 'package-lock.json' const { pkg, pkgFile }: PackageInfo = await loadPackageFileForDoctor(options) // flatten all deps into one so we can iterate over them @@ -232,7 +232,7 @@ const doctor = async (run: Run, options: Options): Promise => { if (lockFile) { await fs.writeFile(lockFileName, lockFile) } else { - await fs.rm(lockFileName) + await fs.rm(lockFileName, { recursive: true, force: true }) } // save the last package file with passing tests diff --git a/test/bin.test.ts b/test/bin.test.ts index 6611c926..83dbe436 100644 --- a/test/bin.test.ts +++ b/test/bin.test.ts @@ -6,6 +6,7 @@ import { Index } from '../src/types/IndexType' import { Version } from '../src/types/Version' import chaiSetup from './helpers/chaiSetup' import stubNpmView from './helpers/stubNpmView' +import { rmOptions } from './helpers/testConstants' chaiSetup() @@ -116,7 +117,7 @@ describe('bin', async function () { const pkgData = JSON.parse(text) pkgData.should.have.property('express') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) stub.restore() } }) @@ -133,7 +134,7 @@ describe('bin', async function () { upgradedPkg.dependencies.should.have.property('express') upgradedPkg.dependencies.express.should.not.equal('1') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) stub.restore() } }) @@ -153,7 +154,7 @@ describe('bin', async function () { upgradedPkg.dependencies.should.have.property('express') upgradedPkg.dependencies.express.should.not.equal('1') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) stub.restore() } }) @@ -170,7 +171,7 @@ describe('bin', async function () { ugradedPkg.dependencies.should.have.property('express') ugradedPkg.dependencies.express.should.not.equal('1') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) stub.restore() } }) @@ -187,7 +188,7 @@ describe('bin', async function () { upgradedPkg.dependencies.should.have.property('express') upgradedPkg.dependencies.express.should.not.equal('1') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) stub.restore() } }) @@ -214,7 +215,7 @@ describe('bin', async function () { const output = await spawn('node', [bin, '--packageFile', pkgFile, '--filter', 'ncu-test-v2 ncu-test-tag']) output.should.include('"ncu-test-v2 ncu-test-tag"') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) stub.restore() } }) diff --git a/test/cache.test.ts b/test/cache.test.ts index b3e86d57..308de642 100644 --- a/test/cache.test.ts +++ b/test/cache.test.ts @@ -5,6 +5,7 @@ import { CACHE_DELIMITER, resolvedDefaultCacheFile } from '../src/lib/cache' import { CacheData } from '../src/types/Cacher' import chaiSetup from './helpers/chaiSetup' import stubNpmView from './helpers/stubNpmView' +import { rmOptions } from './helpers/testConstants' chaiSetup() @@ -35,7 +36,7 @@ describe('cache', () => { [`ncu-test-alpha${CACHE_DELIMITER}latest`]: '1.0.0', }) } finally { - await fs.rm(resolvedDefaultCacheFile) + await fs.rm(resolvedDefaultCacheFile, rmOptions) stub.restore() } }) @@ -95,7 +96,7 @@ describe('cache', () => { [`ncu-test-alpha${CACHE_DELIMITER}greatest`]: '2.0.0-alpha.2', }) } finally { - await fs.rm(resolvedDefaultCacheFile) + await fs.rm(resolvedDefaultCacheFile, rmOptions) stub.restore() } }) diff --git a/test/deep.test.ts b/test/deep.test.ts index f94d0363..8f04b49f 100644 --- a/test/deep.test.ts +++ b/test/deep.test.ts @@ -7,6 +7,7 @@ import ncu from '../src/' import mergeOptions from '../src/lib/mergeOptions' import chaiSetup from './helpers/chaiSetup' import stubNpmView from './helpers/stubNpmView' +import { rmOptions } from './helpers/testConstants' chaiSetup() @@ -65,7 +66,7 @@ describe('--deep', function () { deepJsonOut['packages/sub1/package.json'].dependencies.should.have.property('express') deepJsonOut['packages/sub2/package.json'].dependencies.should.have.property('express') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -85,7 +86,7 @@ describe('--deep', function () { upgradedPkg.dependencies.should.have.property('express') upgradedPkg.dependencies.express.should.not.equal('1') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -115,7 +116,7 @@ describe('--deep', function () { json.should.have.property(path.join(tempDir, 'packages/sub2/package.json').replace(/\\/g, '/')) json.should.have.property(path.join(tempDir, 'package.json').replace(/\\/g, '/')) } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) }) diff --git a/test/dep.test.ts b/test/dep.test.ts index d7335f25..cf190769 100644 --- a/test/dep.test.ts +++ b/test/dep.test.ts @@ -4,6 +4,7 @@ import path from 'path' import ncu from '../src/' import chaiSetup from './helpers/chaiSetup' import stubNpmView from './helpers/stubNpmView' +import { rmOptions } from './helpers/testConstants' chaiSetup() @@ -98,7 +99,7 @@ describe('--dep', () => { }, }) } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) stub.restore() } }) @@ -145,7 +146,7 @@ describe('--dep', () => { }, }) } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) stub.restore() } }) @@ -192,7 +193,7 @@ describe('--dep', () => { }, }) } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) stub.restore() } }) @@ -236,7 +237,7 @@ describe('--dep', () => { }, }) } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) stub.restore() } }) @@ -276,7 +277,7 @@ describe('--dep', () => { }, }) } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) stub.restore() } }) @@ -318,7 +319,7 @@ describe('--dep', () => { }, }) } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) stub.restore() } }) diff --git a/test/doctor.test.ts b/test/doctor.test.ts index 2ad1edb7..af76a3ff 100644 --- a/test/doctor.test.ts +++ b/test/doctor.test.ts @@ -7,6 +7,7 @@ import { chalkInit } from '../src/lib/chalk' import { PackageManagerName } from '../src/types/PackageManagerName' import chaiSetup from './helpers/chaiSetup' import stubNpmView from './helpers/stubNpmView' +import { rmOptions } from './helpers/testConstants' chaiSetup() @@ -68,13 +69,13 @@ const testPass = ({ packageManager }: { packageManager: PackageManagerName }) => // cleanup before assertions in case they fail await fs.writeFile(pkgPath, pkgOriginal) - await fs.rm(nodeModulesPath) - await fs.rm(lockfilePath) + await fs.rm(nodeModulesPath, rmOptions) + await fs.rm(lockfilePath, rmOptions) // delete yarn cache if (packageManager === 'yarn') { - await fs.rm(path.join(cwd, '.yarn')) - await fs.rm(path.join(cwd, '.pnp.js')) + await fs.rm(path.join(cwd, '.yarn'), rmOptions) + await fs.rm(path.join(cwd, '.pnp.js'), rmOptions) } // bun prints the run header to stderr instead of stdout @@ -133,13 +134,13 @@ const testFail = ({ packageManager }: { packageManager: PackageManagerName }) => } finally { pkgUpgraded = await fs.readFile(pkgPath, 'utf-8') await fs.writeFile(pkgPath, pkgOriginal) - await fs.rm(nodeModulesPath) - await fs.rm(lockfilePath) + await fs.rm(nodeModulesPath, rmOptions) + await fs.rm(lockfilePath, rmOptions) // delete yarn cache if (packageManager === 'yarn') { - await fs.rm(path.join(cwd, '.yarn')) - await fs.rm(path.join(cwd, '.pnp.js')) + await fs.rm(path.join(cwd, '.yarn'), rmOptions) + await fs.rm(path.join(cwd, '.pnp.js'), rmOptions) } } @@ -234,8 +235,8 @@ describe('doctor', function () { // cleanup before assertions in case they fail await fs.writeFile(pkgPath, pkgOriginal) - await fs.rm(lockfilePath) - await fs.rm(nodeModulesPath) + await fs.rm(lockfilePath, rmOptions) + await fs.rm(nodeModulesPath, rmOptions) // stderr should be empty stderr.should.equal('') @@ -276,8 +277,8 @@ describe('doctor', function () { // cleanup before assertions in case they fail await fs.writeFile(pkgPath, pkgOriginal) - await fs.rm(lockfilePath) - await fs.rm(nodeModulesPath) + await fs.rm(lockfilePath, rmOptions) + await fs.rm(nodeModulesPath, rmOptions) // stderr should be empty stderr.should.equal('') @@ -317,8 +318,8 @@ describe('doctor', function () { // cleanup before assertions in case they fail await fs.writeFile(pkgPath, pkgOriginal) - await fs.rm(lockfilePath) - await fs.rm(nodeModulesPath) + await fs.rm(lockfilePath, rmOptions) + await fs.rm(nodeModulesPath, rmOptions) // stderr should be empty stderr.should.equal('') @@ -358,8 +359,8 @@ describe('doctor', function () { // cleanup before assertions in case they fail await fs.writeFile(pkgPath, pkgOriginal) - await fs.rm(lockfilePath) - await fs.rm(nodeModulesPath) + await fs.rm(lockfilePath, rmOptions) + await fs.rm(nodeModulesPath, rmOptions) // stderr should be empty stderr.should.equal('') @@ -430,7 +431,7 @@ else { pkgUpgraded = JSON.parse(await fs.readFile(pkgPath, 'utf-8')) } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } // stdout should include successful upgrades diff --git a/test/filterResults.test.ts b/test/filterResults.test.ts index 8f2fec83..e49a47b5 100644 --- a/test/filterResults.test.ts +++ b/test/filterResults.test.ts @@ -5,6 +5,7 @@ import path from 'path' import ncu from '../src/' import chaiSetup from './helpers/chaiSetup' import stubNpmView from './helpers/stubNpmView' +import { rmOptions } from './helpers/testConstants' chaiSetup() @@ -49,7 +50,7 @@ describe('filterResults', () => { expect(upgraded).to.have.property('ncu-test-v2', '3.0.0') expect(upgraded).to.not.have.property('ncu-test-return-version') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) stub.restore() } }) diff --git a/test/format.test.ts b/test/format.test.ts index 5f6ea165..ea7c9f07 100644 --- a/test/format.test.ts +++ b/test/format.test.ts @@ -5,6 +5,7 @@ import path from 'path' import spawn from 'spawn-please' import chaiSetup from './helpers/chaiSetup' import stubNpmView from './helpers/stubNpmView' +import { rmOptions } from './helpers/testConstants' chaiSetup() @@ -49,7 +50,7 @@ describe('format', () => { const output = await spawn('node', [bin, '--format', 'repo'], { cwd: tempDir }) output.should.include('https://github.com/Mitsunee/modern-diacritics') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -77,7 +78,7 @@ describe('format', () => { const output = await spawn('node', [bin, '--format', 'lines'], { cwd: tempDir }) output.should.equals('ncu-test-v2@^2.0.0\nncu-test-tag@^1.1.0\n') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) stub.restore() } }) @@ -107,7 +108,7 @@ describe('format', () => { cwd: tempDir, }).should.eventually.be.rejectedWith('Cannot specify both --format lines and --jsonUpgraded.') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) stub.restore() } }) @@ -137,7 +138,7 @@ describe('format', () => { cwd: tempDir, }).should.eventually.be.rejectedWith('Cannot specify both --format lines and --jsonAll.') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) stub.restore() } }) @@ -167,7 +168,7 @@ describe('format', () => { cwd: tempDir, }).should.eventually.be.rejectedWith('Cannot use --format lines with other formatting options.') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) stub.restore() } }) diff --git a/test/group.test.ts b/test/group.test.ts index a771a345..c15528db 100644 --- a/test/group.test.ts +++ b/test/group.test.ts @@ -5,6 +5,7 @@ import spawn from 'spawn-please' import { GroupFunction } from '../src/types/GroupFunction' import chaiSetup from './helpers/chaiSetup' import stubNpmView from './helpers/stubNpmView' +import { rmOptions } from './helpers/testConstants' chaiSetup() @@ -46,7 +47,7 @@ async function groupTestScaffold( }) stripAnsi(stdout).should.containIgnoreCase(expectedOutput) } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) stub.restore() } } diff --git a/test/helpers/testConstants.ts b/test/helpers/testConstants.ts new file mode 100644 index 00000000..04720682 --- /dev/null +++ b/test/helpers/testConstants.ts @@ -0,0 +1,3 @@ +import { RmOptions } from 'fs' + +export const rmOptions: RmOptions = { recursive: true, force: true } diff --git a/test/index.test.ts b/test/index.test.ts index f0ae32a0..4f9a779b 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -4,6 +4,7 @@ import path from 'path' import ncu from '../src/' import chaiSetup from './helpers/chaiSetup' import stubNpmView from './helpers/stubNpmView' +import { rmOptions } from './helpers/testConstants' chaiSetup() @@ -68,7 +69,7 @@ describe('run', function () { upgradedPkg.should.have.property('dependencies') upgradedPkg.dependencies.should.have.property('express') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) stub.restore() } }) @@ -271,7 +272,7 @@ describe('run', function () { }, }) } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) stub.restore() } }) @@ -317,7 +318,7 @@ describe('run', function () { }, }) } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) stub.restore() } }) @@ -361,7 +362,7 @@ describe('run', function () { }, }) } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) stub.restore() } }) @@ -409,7 +410,7 @@ describe('run', function () { }, }) } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) stub.restore() } }) diff --git a/test/install.test.ts b/test/install.test.ts index af7daac0..a4fc1b1b 100644 --- a/test/install.test.ts +++ b/test/install.test.ts @@ -8,6 +8,7 @@ import spawn from 'spawn-please' import exists from '../src/lib/exists' import chaiSetup from './helpers/chaiSetup' import stubNpmView from './helpers/stubNpmView' +import { rmOptions } from './helpers/testConstants' chaiSetup() @@ -34,7 +35,7 @@ describe('install', () => { expect(await exists(path.join(tempDir, 'package-lock.json'))).to.be.false expect(await exists(path.join(tempDir, 'node_modules'))).to.be.false } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) stub.restore() } }) @@ -58,7 +59,7 @@ describe('install', () => { expect(await exists(path.join(tempDir, 'package-lock.json'))).to.be.true expect(await exists(path.join(tempDir, 'node_modules'))).to.be.true } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) stub.restore() } }) @@ -82,7 +83,7 @@ describe('install', () => { expect(await exists(path.join(tempDir, 'package-lock.json'))).to.be.false expect(await exists(path.join(tempDir, 'node_modules'))).to.be.false } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) stub.restore() } }) @@ -111,7 +112,7 @@ describe('install', () => { expect(await exists(path.join(tempDir, 'package-lock.json'))).to.be.true expect(await exists(path.join(tempDir, 'node_modules'))).to.be.true } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) stub.restore() } }) @@ -138,7 +139,7 @@ describe('install', () => { expect(await exists(path.join(tempDir, 'package-lock.json'))).to.be.false expect(await exists(path.join(tempDir, 'node_modules'))).to.be.false } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) stub.restore() } }) @@ -167,7 +168,7 @@ describe('install', () => { expect(await exists(path.join(tempDir, 'package-lock.json'))).to.be.true expect(await exists(path.join(tempDir, 'node_modules'))).to.be.true } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) stub.restore() } }) @@ -196,7 +197,7 @@ describe('install', () => { expect(await exists(path.join(tempDir, 'package-lock.json'))).to.be.false expect(await exists(path.join(tempDir, 'node_modules'))).to.be.false } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) stub.restore() } }) diff --git a/test/interactive.test.ts b/test/interactive.test.ts index 5e9355e0..1021ef4c 100644 --- a/test/interactive.test.ts +++ b/test/interactive.test.ts @@ -4,6 +4,7 @@ import path from 'path' import spawn from 'spawn-please' import chaiSetup from './helpers/chaiSetup' import stubNpmView from './helpers/stubNpmView' +import { rmOptions } from './helpers/testConstants' const should = chaiSetup() @@ -59,7 +60,7 @@ describe('--interactive', () => { 'ncu-test-tag': '1.0.0', }) } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -93,7 +94,7 @@ describe('--interactive', () => { // prompts does not print during injection, so we cannot assert the output in interactive mode } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -133,7 +134,7 @@ describe('--interactive', () => { // prompts does not print during injection, so we cannot assert the output in interactive mode } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -161,7 +162,7 @@ describe('--interactive', () => { output.should.include('https://github.com/Mitsunee/modern-diacritics') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) }) diff --git a/test/package-managers/deno/index.test.ts b/test/package-managers/deno/index.test.ts index 5b8b873a..3c446bee 100644 --- a/test/package-managers/deno/index.test.ts +++ b/test/package-managers/deno/index.test.ts @@ -28,7 +28,7 @@ describe('deno', async function () { const pkg = jph.parse(pkgData) pkg.should.have.property('ncu-test-v2') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -48,7 +48,7 @@ describe('deno', async function () { const pkg = jph.parse(pkgData) pkg.should.have.property('ncu-test-v2') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -71,7 +71,7 @@ describe('deno', async function () { }, }) } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -92,7 +92,7 @@ describe('deno', async function () { const pkg = jph.parse(pkgData) pkg.should.have.property('ncu-test-v2') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -115,7 +115,7 @@ describe('deno', async function () { }, }) } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) }) diff --git a/test/peer.test.ts b/test/peer.test.ts index b89dec9e..7fa05ae0 100644 --- a/test/peer.test.ts +++ b/test/peer.test.ts @@ -3,6 +3,7 @@ import path from 'path' import ncu from '../src/' import spawnNpm from '../src/package-managers/npm' import chaiSetup from './helpers/chaiSetup' +import { rmOptions } from './helpers/testConstants' chaiSetup() @@ -16,8 +17,8 @@ describe('peer dependencies', function () { 'ncu-test-return-version': '2.0.0', }) } finally { - await fs.rm(path.join(cwd, 'node_modules')) - await fs.rm(path.join(cwd, 'package-lock.json')) + await fs.rm(path.join(cwd, 'node_modules'), rmOptions) + await fs.rm(path.join(cwd, 'package-lock.json'), rmOptions) } }) @@ -30,8 +31,8 @@ describe('peer dependencies', function () { 'ncu-test-return-version': '1.1.0', }) } finally { - await fs.rm(path.join(cwd, 'node_modules')) - await fs.rm(path.join(cwd, 'package-lock.json')) + await fs.rm(path.join(cwd, 'node_modules'), rmOptions) + await fs.rm(path.join(cwd, 'package-lock.json'), rmOptions) } }) @@ -45,8 +46,8 @@ describe('peer dependencies', function () { 'ncu-test-peer-update': '1.1.0', }) } finally { - await fs.rm(path.join(cwd, 'node_modules')) - await fs.rm(path.join(cwd, 'package-lock.json')) + await fs.rm(path.join(cwd, 'node_modules'), rmOptions) + await fs.rm(path.join(cwd, 'package-lock.json'), rmOptions) } }) }) diff --git a/test/rc-config.test.ts b/test/rc-config.test.ts index 46a39204..c873ecf8 100644 --- a/test/rc-config.test.ts +++ b/test/rc-config.test.ts @@ -4,6 +4,7 @@ import path from 'path' import spawn from 'spawn-please' import chaiSetup from './helpers/chaiSetup' import stubNpmView from './helpers/stubNpmView' +import { rmOptions } from './helpers/testConstants' chaiSetup() @@ -27,7 +28,7 @@ describe('rc-config', () => { ) text.should.containIgnoreCase(`Using config file ${tempConfigFile}`) } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -41,7 +42,7 @@ describe('rc-config', () => { ) text.should.not.include('Using config file') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -57,7 +58,7 @@ describe('rc-config', () => { ) text.should.not.include('Using config file') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -75,7 +76,7 @@ describe('rc-config', () => { pkgData.should.have.property('ncu-test-v2') pkgData.should.not.have.property('ncu-test-tag') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -94,7 +95,7 @@ describe('rc-config', () => { pkgData.should.have.property('ncu-test-v2') pkgData.should.not.have.property('ncu-test-tag') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -112,7 +113,7 @@ describe('rc-config', () => { pkgData.should.have.property('ncu-test-tag') pkgData.should.not.have.property('ncu-test-v2') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -129,7 +130,7 @@ describe('rc-config', () => { // if the output contains "Using config file", then we know that jsonUpgraded was overridden output.should.include('Using config file') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -147,7 +148,7 @@ describe('rc-config', () => { const pkgData = JSON.parse(text) pkgData.should.have.property('ncu-test-tag') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -171,7 +172,7 @@ describe('rc-config', () => { firstLine.should.contains('Using config file') firstLine.should.contains(configFile) } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -195,7 +196,7 @@ describe('rc-config', () => { firstLine.should.contains('Using config file') firstLine.should.contains(configFile) } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -210,7 +211,7 @@ describe('rc-config', () => { // awkwardly, we have to set mergeConfig to enable autodetecting the rcconfig because otherwise it is explicitly disabled for tests await spawn('node', [bin, '--mergeConfig'], { cwd: tempDir }) } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) }) diff --git a/test/workspaces.test.ts b/test/workspaces.test.ts index 3d64732d..1d4644bd 100644 --- a/test/workspaces.test.ts +++ b/test/workspaces.test.ts @@ -141,7 +141,7 @@ describe('workspaces', () => { output.should.not.have.property('packages/b/package.json') output['packages/a/package.json'].dependencies.should.have.property('ncu-test-tag') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -154,7 +154,7 @@ describe('workspaces', () => { output['packages/a/package.json'].dependencies.should.have.property('ncu-test-tag') output['packages/b/package.json'].dependencies.should.have.property('ncu-test-return-version') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -167,7 +167,7 @@ describe('workspaces', () => { output['packages/a/package.json'].dependencies.should.have.property('ncu-test-tag') output['packages/b/package.json'].dependencies.should.have.property('ncu-test-return-version') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -192,7 +192,7 @@ describe('workspaces', () => { output['packages/a/package.json'].dependencies.should.have.property('ncu-test-tag') output['packages/b/package.json'].dependencies.should.have.property('ncu-test-return-version') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -207,7 +207,7 @@ describe('workspaces', () => { output['packages/a/package.json'].dependencies.should.have.property('ncu-test-tag') output['packages/b/package.json'].dependencies.should.have.property('ncu-test-return-version') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -228,7 +228,7 @@ describe('workspaces', () => { }, }) } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -248,7 +248,7 @@ describe('workspaces', () => { }, }) } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) }) @@ -272,7 +272,7 @@ describe('workspaces', () => { output.should.not.have.property('packages/b/package.json') output['packages/a/package.json'].dependencies.should.have.property('ncu-test-tag') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -284,7 +284,7 @@ describe('workspaces', () => { output.should.not.have.property('packages/b/package.json') output['packages/a/package.json'].dependencies.should.have.property('ncu-test-tag') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -299,7 +299,7 @@ describe('workspaces', () => { output['packages/a/package.json'].dependencies.should.have.property('ncu-test-tag') output['packages/b/package.json'].dependencies.should.have.property('ncu-test-return-version') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -314,7 +314,7 @@ describe('workspaces', () => { output.should.not.have.property('packages/b/package.json') output['packages/a/package.json'].dependencies.should.have.property('ncu-test-tag') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -332,7 +332,7 @@ describe('workspaces', () => { }, }) } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) }) @@ -353,7 +353,7 @@ describe('workspaces', () => { output['packages/a/package.json'].dependencies.should.have.property('ncu-test-tag') output['packages/b/package.json'].dependencies.should.have.property('ncu-test-return-version') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -369,7 +369,7 @@ describe('workspaces', () => { output['packages/a/package.json'].dependencies.should.have.property('ncu-test-tag') output['packages/b/package.json'].dependencies.should.have.property('ncu-test-return-version') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -392,7 +392,7 @@ describe('workspaces', () => { upgradedPkgB.dependencies.should.have.property('ncu-test-return-version') upgradedPkgB.dependencies['ncu-test-return-version'].should.not.equal('1.0.0') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -419,7 +419,7 @@ describe('workspaces', () => { output['packages/a/package.json'].dependencies.should.have.property('ncu-test-tag') output['packages/b/package.json'].dependencies.should.have.property('ncu-test-return-version') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) }) @@ -437,7 +437,7 @@ describe('workspaces', () => { output['package.json'].dependencies.should.have.property('ncu-test-v2') output['packages/a/package.json'].dependencies.should.have.property('ncu-test-tag') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) @@ -454,7 +454,7 @@ describe('workspaces', () => { output['packages/a/package.json'].dependencies.should.have.property('ncu-test-tag') output['packages/b/package.json'].dependencies.should.have.property('ncu-test-return-version') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) }) @@ -469,7 +469,7 @@ describe('workspaces', () => { output['packages/a/package.json'].dependencies.should.have.property('ncu-test-tag') output['packages/b/package.json'].dependencies.should.have.property('ncu-test-return-version') } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) }) @@ -491,7 +491,7 @@ describe('workspaces', () => { output.should.include(`npm config (workspace project):\n{ ncutest: 'root' }`) output.should.include(`Using merged npm config:\n{\n ncutest: 'a',`) } finally { - await fs.rm(tempDir, { recursive: true, force: true }) + await fs.rm(tempDir, rmOptions) } }) })