-
Notifications
You must be signed in to change notification settings - Fork 3.4k
chore: convert additional server files to TypeScript #32950
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
Merged
+592
−583
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2cf1ab3
chore: convert server files p3
AtofStryker 0e66754
does deleting this break anything? looks unused
AtofStryker ed4dbc4
chore: convert tty to TS
AtofStryker b0bdaa7
convert terminal util to TS
AtofStryker 019752b
convert status code to TS
AtofStryker 2ec5299
chore: convert system util to TS
AtofStryker d072ec4
convert resolve to ts (tsx works inside child process)
AtofStryker be4bd83
empty commit
AtofStryker 0625ed6
add comments to ts-expect-error
AtofStryker 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
File renamed without changes.
File renamed without changes.
This file contains hidden or 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 hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import path from 'path' | ||
| import { fs } from './util/fs' | ||
|
|
||
| export async function readFile (projectRoot: string, options: { file: string, encoding?: BufferEncoding } = { file: '', encoding: 'utf8' }) { | ||
| const filePath = path.resolve(projectRoot, options.file) | ||
|
|
||
| // https://github.com/cypress-io/cypress/issues/1558 | ||
| // If no encoding is specified, then Cypress has historically defaulted | ||
| // to `utf8`, because of it's focus on text files. This is in contrast to | ||
| // NodeJs, which defaults to binary. We allow users to pass in `null` | ||
| // to restore the default node behavior. | ||
| try { | ||
| let contents | ||
|
|
||
| if (path.extname(filePath) === '.json' && options.encoding !== null) { | ||
| contents = await fs.readJsonAsync(filePath, options.encoding === undefined ? 'utf8' : options.encoding) | ||
| } else { | ||
| contents = await fs.readFileAsync(filePath, { | ||
| encoding: options.encoding === undefined ? 'utf8' : options.encoding, | ||
| }) | ||
| } | ||
|
|
||
| return { | ||
| contents, | ||
| filePath, | ||
| } | ||
| } catch (err) { | ||
| err.originalFilePath = options.file | ||
| err.filePath = filePath | ||
| throw err | ||
| } | ||
| } | ||
|
|
||
| export async function readFiles (projectRoot: string, options: { files: { path: string, encoding?: BufferEncoding }[] } = { files: [] }) { | ||
| const files = await Promise.all(options.files.map(async (file) => { | ||
| const { contents, filePath } = await readFile(projectRoot, { | ||
| file: file.path, | ||
| encoding: file.encoding, | ||
| }) | ||
|
|
||
| return { | ||
| ...file, | ||
| filePath, | ||
| contents, | ||
| } | ||
| })) | ||
|
|
||
| return files | ||
| } | ||
AtofStryker marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| export async function writeFile (projectRoot: string, options: { fileName: string, contents: string, encoding?: BufferEncoding, flag?: string } = { fileName: '', contents: '', encoding: 'utf8', flag: 'w' }) { | ||
| const filePath = path.resolve(projectRoot, options.fileName) | ||
| const writeOptions = { | ||
| encoding: options.encoding === undefined ? 'utf8' : options.encoding, | ||
| flag: options.flag || 'w', | ||
| } | ||
|
|
||
| try { | ||
| await fs.outputFile(filePath, options.contents, writeOptions) | ||
|
|
||
| return { | ||
| contents: options.contents, | ||
| filePath, | ||
| } | ||
| } catch (err) { | ||
| err.filePath = filePath | ||
| throw err | ||
| } | ||
| } | ||
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.