Skip to content

Commit

Permalink
feat: support multiple glob patterns (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
dwightjack committed Oct 27, 2022
1 parent 12709f6 commit b339163
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ While there are tools like [tsc](https://www.typescriptlang.org/docs/handbook/co
## 🚀 Usage

```bash
npx mkdist [rootDir] [--src=src] [--dist=dist] [--pattern=glob] [--format=cjs|esm] [-d|--declaration] [--ext=mjs|js|ts]
npx mkdist [rootDir] [--src=src] [--dist=dist] [--pattern=glob [--pattern=more-glob]] [--format=cjs|esm] [-d|--declaration] [--ext=mjs|js|ts]
```
## License
Expand Down
2 changes: 1 addition & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ async function main () {

if (args.help) {
// eslint-disable-next-line no-console
console.log('Usage: npx mkdist [rootDir] [--src=src] [--dist=dist] [--pattern=glob] [--format=cjs|esm] [-d|--declaration] [--ext=mjs|js|ts]')
console.log('Usage: npx mkdist [rootDir] [--src=src] [--dist=dist] [--pattern=glob [--pattern=more-glob]] [--format=cjs|esm] [-d|--declaration] [--ext=mjs|js|ts]')
process.exit(0)
}

Expand Down
2 changes: 1 addition & 1 deletion src/make.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getDeclarations } from './utils/dts'
export interface MkdistOptions extends LoaderOptions {
rootDir?: string
srcDir?: string
pattern?: string
pattern?: string | string[]
distDir?: string
cleanDist?: boolean
}
Expand Down
10 changes: 10 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ describe('mkdist', () => {
].map(f => resolve(rootDir, f)).sort())
})

it('mkdist (multiple glob patterns)', async () => {
const rootDir = resolve(__dirname, 'fixture')
const { writtenFiles } = await mkdist({ rootDir, pattern: ['components/**', '!components/js.vue'] })
expect(writtenFiles.sort()).toEqual([
'dist/components/blank.vue',
'dist/components/script-setup-ts.vue',
'dist/components/ts.vue'
].map(f => resolve(rootDir, f)).sort())
})

it('mkdist (emit types)', async () => {
const rootDir = resolve(__dirname, 'fixture')
const { writtenFiles } = await mkdist({ rootDir, declaration: true })
Expand Down

0 comments on commit b339163

Please sign in to comment.