| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- // @ts-check
- import fs from 'node:fs'
- import chalk from 'chalk'
- import { createRequire } from 'node:module'
- const require = createRequire(import.meta.url)
- export const targets = fs.readdirSync('packages').filter(f => {
- if (!fs.statSync(`packages/${f}`).isDirectory()) {
- return false
- }
- const pkg = require(`../packages/${f}/package.json`)
- if (pkg.private && !pkg.buildOptions) {
- return false
- }
- return true
- })
- export function fuzzyMatchTarget(partialTargets, includeAllMatching) {
- const matched = []
- partialTargets.forEach(partialTarget => {
- for (const target of targets) {
- if (target.match(partialTarget)) {
- matched.push(target)
- if (!includeAllMatching) {
- break
- }
- }
- }
- })
- if (matched.length) {
- return matched
- } else {
- console.log()
- console.error(
- ` ${chalk.bgRed.white(' ERROR ')} ${chalk.red(
- `Target ${chalk.underline(partialTargets)} not found!`
- )}`
- )
- console.log()
- process.exit(1)
- }
- }
|