Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support multiple glob patterns #41

Merged
merged 1 commit into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -6,7 +6,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 @@ -34,6 +34,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