Skip to content

Commit

Permalink
fix(test): Support single-package testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Meqn committed Jan 7, 2024
1 parent 728a233 commit 42567de
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions scripts/test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
const minimist = require('minimist')
const rawArgs = process.argv.slice(2)
const args = minimist(rawArgs)
const packageNames = ['core', 'cli', 'main', 'utils']

let regex
if (args.p) {
const packages = (args.p || args.package).split(',').join('|')
regex = `packages/(${packages})/.*\\.(test|spec)\\.js$`
const i = rawArgs.indexOf('-p')
rawArgs.splice(i, 2)
} else if (args._.length && packageNames.includes(args._[0])) {
// 支持 `pnpm test core`
regex = `packages/(${args._[0]})/.*\\.(test|spec)\\.js$`
rawArgs.shift()
}

const jestArgs = [
Expand Down

0 comments on commit 42567de

Please sign in to comment.