diff --git a/lib/config.js b/lib/config.js index 4bcc36d1..789cb5c2 100644 --- a/lib/config.js +++ b/lib/config.js @@ -1,5 +1,6 @@ const { relative, dirname, join, extname } = require('path') const { defaults, defaultsDeep, pick, omit, uniq, isPlainObject } = require('lodash') +const semver = require('semver') const ciVersions = require('./util/ci-versions.js') const parseDependabot = require('./util/dependabot.js') const git = require('./util/git.js') @@ -165,6 +166,8 @@ const getFullConfig = async ({ esm, cjsExt: esm ? 'cjs' : 'js', deleteJsExt: esm ? 'js' : 'cjs', + // tap + tap18: semver.coerce(pkg.pkgJson?.devDependencies?.tap)?.major === 18, // booleans to control application of updates isForce, isDogFood, diff --git a/lib/content/package-json.hbs b/lib/content/package-json.hbs index 5282f19f..bba7ebdf 100644 --- a/lib/content/package-json.hbs +++ b/lib/content/package-json.hbs @@ -34,13 +34,13 @@ {{#if workspacePaths}} "test-ignore": "^({{ join workspacePaths "|" }})/", {{/if}} - "nyc-arg": [ + "nyc-arg": {{#if tap18}}{{{ del }}}{{else}}[ {{#each workspaceGlobs}} "--exclude", "{{ . }}", {{/each}} "--exclude", "tap-snapshots/**" - ] + ]{{/if}} } } diff --git a/test/apply/tap.js b/test/apply/tap.js new file mode 100644 index 00000000..2a204877 --- /dev/null +++ b/test/apply/tap.js @@ -0,0 +1,37 @@ +const t = require('tap') +const setup = require('../setup.js') + +t.test('tap@18', async (t) => { + const s = await setup(t, { + ok: true, + package: { + devDependencies: { + tap: '^18', + }, + }, + }) + + await s.apply() + const pkg = await s.readJson('package.json') + t.strictSame(pkg.tap, {}) +}) + +t.test('tap@16', async (t) => { + const s = await setup(t, { + ok: true, + package: { + devDependencies: { + tap: '^16', + }, + }, + }) + + await s.apply() + const pkg = await s.readJson('package.json') + t.strictSame(pkg.tap, { + 'nyc-arg': [ + '--exclude', + 'tap-snapshots/**', + ], + }) +})