Update some readFileSync to await readFile with top level await (#20525)
* Update some readFileSync to await readFile with top level await * More updates * Update all-products.js * Use 'lib/readfile-async.js' in runtime files for better performance * Remove unnecessary use of 'for await...of' loops * Revert to importing 'fs/promises' Co-authored-by: James M. Greene <jamesmgreene@github.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
import fs from 'fs'
|
||||
import fs from 'fs/promises'
|
||||
import path from 'path'
|
||||
import program from 'commander'
|
||||
import yaml from 'js-yaml'
|
||||
@@ -43,7 +43,7 @@ if (!Object.keys(allVersions).includes(options.version)) {
|
||||
}
|
||||
|
||||
// Load the release candidate variable
|
||||
const releaseCandidateData = yaml.load(fs.readFileSync(releaseCandidateYaml, 'utf8'))
|
||||
const releaseCandidateData = yaml.load(await fs.readFile(releaseCandidateYaml, 'utf8'))
|
||||
|
||||
// Create or remove the variable
|
||||
if (options.action === 'create') {
|
||||
@@ -55,7 +55,7 @@ if (options.action === 'remove') {
|
||||
}
|
||||
|
||||
// Update the file
|
||||
fs.writeFileSync(releaseCandidateYaml, yaml.dump(releaseCandidateData))
|
||||
await fs.writeFile(releaseCandidateYaml, yaml.dump(releaseCandidateData))
|
||||
|
||||
// Display next steps
|
||||
console.log(`\nDone! Commit the update to ${releaseCandidateFile}. This ${options.action}s the banner for ${options.version}.
|
||||
|
||||
Reference in New Issue
Block a user