Skip to content

Commit

Permalink
added: extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
binjospookie committed Dec 28, 2023
1 parent eb33bf5 commit 1cd2713
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions bin/collectUsages.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { createStatusAPI } from './utils/index.js'
* config: {
* collectUsages: string
* exclude: Set<string>
* extensions: Array<string>
* babelPlugins: Set<string>
* batch: {
* default: number
Expand Down
10 changes: 9 additions & 1 deletion bin/fileTraversal/getFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ import { fdir } from 'fdir'
const getRepoRoot = () =>
execSync('git rev-parse --show-toplevel', { encoding: 'utf8' }).trim()

const formattedExtensions = list =>
list.reduce((acc, ext) => acc + (acc ? ',' : '') + ext.slice(1), '')

/**
* @param {{
* config: {
* exclude: Set<string>
* extensions: Array<string>
* }
* pkg: {
* name: string
Expand All @@ -30,7 +34,11 @@ const getFiles = async ({ config, pkg }) => {
.join('|')
const excludeRegExp = new RegExp(exclude)
const repoRoot = getRepoRoot()
const source = join(repoRoot, '**', '*.{ts,tsx}')
const source = join(
repoRoot,
'**',
`*.{${formattedExtensions(config.extensions)}}`
)

const files = new fdir()
.exclude(dirName => excludeRegExp.test(dirName))
Expand Down
1 change: 1 addition & 0 deletions bin/fileTraversal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getFiles } from './getFiles.js'
* cmd: {function(_: string): void}
* config: {
* exclude: Set<string>
* extensions: Array<string>
* babelPlugins: Set<string>
* batch: {
* default: number
Expand Down
13 changes: 8 additions & 5 deletions bin/getConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import { lilconfig } from 'lilconfig'
import meow from 'meow'

const BASE_CONFIG = {
entry: 'index.ts',
exclude: new Set(['node_modules']),
babelPlugins: new Set(['typescript']),
batch: { default: 100 },
collectUsages: null
collectUsages: null,
entry: 'index.ts',
exclude: new Set(['node_modules']),
extensions: ['.ts', '.tsx']
}

const cli = meow(
Expand Down Expand Up @@ -41,7 +42,8 @@ const getConfig = async () => {
exclude = [],
babelPlugins = [],
entry = BASE_CONFIG.entry,
batch = {}
batch = {},
extensions = BASE_CONFIG.extensions
} = result.config

return result === null
Expand All @@ -53,7 +55,8 @@ const getConfig = async () => {
batch: {
default: batch.default || BASE_CONFIG.batch.defaul
},
collectUsages: cli.flags.collectUsages || BASE_CONFIG.collectUsages
collectUsages: cli.flags.collectUsages || BASE_CONFIG.collectUsages,
extensions
}
}

Expand Down
1 change: 1 addition & 0 deletions bin/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { createStatusAPI, readJSON } from './utils/index.js'
* config: {
* entry: string
* exclude: Set<string>
* extensions: Array<string>
* babelPlugins: Set<string>
* batch: {
* default: number
Expand Down

0 comments on commit 1cd2713

Please sign in to comment.