-
Notifications
You must be signed in to change notification settings - Fork 734
refactor(fs): use fs instead of fs-extra in copyFiles.
#5761
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
Changes from all commits
bb7d90c
823d6f7
54ae361
f246422
19525fe
1b5ff35
2fd7868
5256feb
7ed0296
21f1728
9c23639
5b72dd0
1bd5782
7c5e40f
be2e88d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ | |
| */ | ||
|
|
||
| /* eslint-disable no-restricted-imports */ | ||
| import * as fs from 'fs-extra' | ||
| import fs from 'fs' | ||
| import * as path from 'path' | ||
|
|
||
| // Moves all dependencies into `dist` | ||
|
|
@@ -46,27 +46,28 @@ const tasks: CopyTask[] = [ | |
| }, | ||
| ] | ||
|
|
||
| async function copy(task: CopyTask): Promise<void> { | ||
| function copy(task: CopyTask): void { | ||
| const src = path.resolve(projectRoot, task.target) | ||
| const dst = path.resolve(outRoot, task.destination ?? task.target) | ||
|
|
||
| try { | ||
| await fs.copy(src, dst, { | ||
| fs.cpSync(src, dst, { | ||
| recursive: true, | ||
| overwrite: true, | ||
| force: true, | ||
| errorOnExist: false, | ||
| }) | ||
| } catch (error) { | ||
| throw new Error(`Copy "${src}" to "${dst}" failed: ${error instanceof Error ? error.message : error}`) | ||
| } | ||
| } | ||
|
|
||
| void (async () => { | ||
| function main() { | ||
| try { | ||
| await Promise.all(tasks.map(copy)) | ||
| tasks.map(copy) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a bit surprising that we were running copy tasks in parallel. I doubt that gives much of a speedup, and it makes the logs less readable, and it could lead to weird races. I think this is better now. |
||
| } catch (error) { | ||
| console.error('`copyFiles.ts` failed') | ||
| console.error(error) | ||
| process.exit(1) | ||
| } | ||
| })() | ||
| } | ||
|
|
||
| void main() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could avoid the formal dependency on
@types/node@22by casting this toany. We normally wouldn't do that, but it may be fine in this case because it avoids confusion, since our packages/ depend on@types/node@16(and that's intentional because vscode ships with node 16).We can add a check to
techdebt.test.tsto remind us to revisit this when we bump to node 18:aws-toolkit-vscode/packages/core/src/test/techdebt.test.ts
Lines 30 to 35 in 6fa3a9e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, so once we update to 18, we will have
@types/node@18which should allow us to remove the any?Also, tracking as a follow-up.