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

chore: use glob to select files in buildTs script #13850

Merged
merged 2 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"execa": "^5.0.0",
"find-process": "^1.4.1",
"glob": "^8.0.0",
"globby": "^11.0.1",
"graceful-fs": "^4.2.9",
"isbinaryfile": "^5.0.0",
"istanbul-lib-coverage": "^3.0.0",
Expand Down
11 changes: 6 additions & 5 deletions scripts/buildTs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as os from 'os';
import * as path from 'path';
import chalk from 'chalk';
import execa from 'execa';
import globby from 'globby';
import glob from 'glob';
import fs from 'graceful-fs';
import pLimit from 'p-limit';
import stripJsonComments from 'strip-json-comments';
Expand Down Expand Up @@ -125,12 +125,13 @@ try {
await Promise.all(
packagesWithTs.map(({packageDir, pkg}) =>
mutex(async () => {
const buildDir = path.resolve(packageDir, 'build/**/*.d.ts');
Copy link
Contributor Author

@mrazauskas mrazauskas Feb 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this should not work on Windows, because the resulting pattern will have \ separators. Hence it should not select any files.

glob has the cwd option to solve this problem.


const globbed = await globby([buildDir]);
const matched = await glob.sync('build/**/*.d.ts', {
SimenB marked this conversation as resolved.
Show resolved Hide resolved
absolute: true,
cwd: packageDir,
});

const files = await Promise.all(
globbed.map(file =>
matched.map(file =>
Promise.all([file, fs.promises.readFile(file, 'utf8')]),
),
);
Expand Down
1 change: 0 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2819,7 +2819,6 @@ __metadata:
execa: ^5.0.0
find-process: ^1.4.1
glob: ^8.0.0
globby: ^11.0.1
graceful-fs: ^4.2.9
isbinaryfile: ^5.0.0
istanbul-lib-coverage: ^3.0.0
Expand Down