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

fix: ensure glob handles dot files correctly #373

Merged
merged 2 commits into from
Dec 2, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/analyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export default async function analyze(id: string, code: string, job: Job): Promi
if (job.log)
console.log('Globbing ' + assetDirPath + wildcardPattern);
const files = (await new Promise<string[]>((resolve, reject) =>
glob(assetDirPath + wildcardPattern, { mark: true, ignore: assetDirPath + '/**/node_modules/**/*' }, (err, files) => err ? reject(err) : resolve(files))
glob(assetDirPath + wildcardPattern, { mark: true, ignore: assetDirPath + '/**/node_modules/**/*', dot: true }, (err, files) => err ? reject(err) : resolve(files))
));
files
.filter(name =>
Expand Down
2 changes: 1 addition & 1 deletion src/utils/sharedlib-emit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function sharedLibEmit(path: string, job: Job) {
return;

const files = await new Promise<string[]>((resolve, reject) =>
glob(pkgPath + sharedlibGlob, { ignore: pkgPath + '/**/node_modules/**/*' }, (err, files) => err ? reject(err) : resolve(files))
glob(pkgPath + sharedlibGlob, { ignore: pkgPath + '/**/node_modules/**/*', dot: true }, (err, files) => err ? reject(err) : resolve(files))
);
await Promise.all(files.map(file => job.emitFile(file, 'sharedlib', path)));
};
16 changes: 16 additions & 0 deletions test/unit/glob-dot/input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const fs = require('fs');

const dotFiles = fs.readdirSync(
__dirname,
'with-dot'
)

const nonDotFiles = fs.readdirSync(
__dirname,
'without-dot'
)

console.log({
dotFiles,
nonDotFiles
});
7 changes: 7 additions & 0 deletions test/unit/glob-dot/output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
"package.json",
"test/unit/glob-dot/input.js",
"test/unit/glob-dot/output.js",
"test/unit/glob-dot/with-dot/.dot/first.txt",
"test/unit/glob-dot/without-dot/normal/first.txt"
]
1 change: 1 addition & 0 deletions test/unit/glob-dot/with-dot/.dot/first.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello
1 change: 1 addition & 0 deletions test/unit/glob-dot/without-dot/normal/first.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello