Skip to content

Commit

Permalink
added: collectUsages flag
Browse files Browse the repository at this point in the history
  • Loading branch information
binjospookie committed Dec 27, 2023
1 parent ddcf110 commit e5b60f7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
9 changes: 6 additions & 3 deletions bin/getConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ const BASE_CONFIG = {
entry: 'index.ts',
exclude: new Set(['node_modules']),
babelPlugins: new Set(['typescript']),
batch: { default: 100 }
batch: { default: 100 },
collectUsages: null
}

const cli = meow(
Expand All @@ -19,7 +20,8 @@ const cli = meow(
allowUnknownFlags: false,
description: false,
flags: {
entry: { type: 'string', shortFlag: 'e' }
entry: { type: 'string', shortFlag: 'e' },
collectUsages: { type: 'string', shortFlag: 'u' }
}
}
)
Expand Down Expand Up @@ -49,7 +51,8 @@ const getConfig = async () => {
babelPlugins: new Set([...BASE_CONFIG.babelPlugins, ...babelPlugins]),
batch: {
default: batch.default || BASE_CONFIG.batch.defaul
}
},
collectUsages: cli.flags.collectUsages || BASE_CONFIG.collectUsages
}
}

Expand Down
4 changes: 4 additions & 0 deletions bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import { createStatusAPI, readJSON } from './utils/index.js'

const config = await getConfig()

if (config.collectUsages) {
process.exit(0)
}

const { name } = await readJSON('package.json')
const pkg = { name, path: process.cwd() }
const statusApi = createStatusAPI({ pkg })
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pure-index",
"type": "module",
"version": "0.0.11",
"version": "0.0.15",
"description": "Utility for monorepos. It helps to find unused exports from packages.",
"main": "./bin/index.js",
"bin": "./bin/index.js",
Expand Down

0 comments on commit e5b60f7

Please sign in to comment.