-
-
Notifications
You must be signed in to change notification settings - Fork 744
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: file write errors for tools and newsroom video #3297
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d958b29
path udpate
vishvamsinh28 8003bff
Merge branch 'master' into toolsPath
vishvamsinh28 54c24c9
fef
vishvamsinh28 b80925c
added retry mechanicasm for enoent errors
vishvamsinh28 6ecff65
use fs extra
vishvamsinh28 d43663d
test updated
vishvamsinh28 8385d7c
Merge branch 'master' into toolsPath
anshgoyalevil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
const { readFileSync, rmSync, mkdirSync } = require('fs'); | ||
const { resolve } = require('path'); | ||
const { readFileSync, removeSync, mkdirpSync } = require('fs-extra'); | ||
const { resolve, join } = require('path'); | ||
const { buildNewsroomVideos } = require('../scripts/build-newsroom-videos'); | ||
const { mockApiResponse, expectedResult } = require('./fixtures/newsroomData'); | ||
const fetch = require('node-fetch-2'); | ||
const os = require('os'); | ||
|
||
jest.mock('node-fetch-2', () => jest.fn()); | ||
|
||
describe('buildNewsroomVideos', () => { | ||
const testDir = resolve(__dirname, 'test_config'); | ||
const testDir = join(os.tmpdir(), 'test_config'); | ||
const testFilePath = resolve(testDir, 'newsroom_videos.json'); | ||
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. This is a nice addition. We should use |
||
|
||
beforeAll(() => { | ||
mkdirSync(testDir, { recursive: true }); | ||
mkdirpSync(testDir); | ||
process.env.YOUTUBE_TOKEN = 'testkey'; | ||
}); | ||
|
||
afterAll(() => { | ||
rmSync(testDir, { recursive: true, force: true }); | ||
removeSync(testDir); | ||
}); | ||
|
||
beforeEach(() => { | ||
|
@@ -89,13 +90,12 @@ describe('buildNewsroomVideos', () => { | |
json: jest.fn().mockResolvedValue(mockApiResponse), | ||
}); | ||
|
||
const invalidPath = '/invalid_dir/newsroom_videos.json'; | ||
const invalidPath = resolve(os.tmpdir(), 'invalid_dir', 'newsroom_videos.json'); | ||
|
||
try { | ||
await buildNewsroomVideos(invalidPath); | ||
} catch (err) { | ||
expect(err.message).toMatch(/ENOENT|EACCES/); | ||
} | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
💡 Codebase verification
Native
fs
module is still widely used - migration tofs-extra
is incompleteThe codebase shows inconsistent usage of file system modules:
fs-extra
is only used in 4 files:build-tools.js
,build-tools.test.js
,build-newsroom-videos.js
, andbuild-newsroom-videos.test.js
fs
moduleSince the PR's objective was to switch from native
fs
tofs-extra
for better error handling and async operations, the migration appears to be incomplete. The changes should be consistent across the codebase to:fs-extra
's enhanced features uniformly🔗 Analysis chain
LGTM! Consider adding @types/fs-extra for TypeScript support.
The addition of fs-extra is appropriate for enhanced file system operations and better error handling. Since this project uses TypeScript, consider adding
@types/fs-extra
to devDependencies for improved type safety.Let's verify the fs-extra usage across the codebase:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 1781