Skip to content

Commit

Permalink
refactor(sample): file filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Airkro committed Sep 20, 2024
1 parent 270ad08 commit 542d3fe
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"bin": {
"bring-it": "dist/bin.mjs"
},
"main": "dist/sub.mjs",
"main": "src/cmd.mjs",
"files": [
"dist"
],
Expand Down
2 changes: 1 addition & 1 deletion packages/sample/src/lib/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function mergeConfig(group = [{}]) {
title = '示例软件名称',
version = 'v1.0',
cwd = '.',
pattern = ['**/*.*'],
pattern = ['**/*'],
ignore = ['dist'],
extensions = [
['js', 'cjs', 'mjs', 'jsx'],
Expand Down
10 changes: 6 additions & 4 deletions packages/sample/src/lib/picker.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { readFile } from 'node:fs/promises';
import { join } from 'node:path';
import { extname, join } from 'node:path';

import { globby } from 'globby';

Expand Down Expand Up @@ -70,10 +70,12 @@ export function scan(config) {
onlyFiles: true,
dot: true,
caseSensitiveMatch: false,
expandDirectories: {
extensions: config.extensions,
},
})
.then((list) =>
list.filter((item) =>
config.extensions.includes(extname(item).replace(/^\./, '')),
),
)
.then((list) => list.sort())
.then((list) => {
for (const item of list) {
Expand Down

0 comments on commit 542d3fe

Please sign in to comment.