1
0
mirror of synced 2025-12-23 21:07:12 -05:00

Use promisified fs.readFile instead of fs.promises.readFile (#18204)

* Create a readFileAsync wrapper module

* Use the readFileAsync wrapper module instead of fs.promises.readFile

* Fix require path in test
This commit is contained in:
James M. Greene
2021-03-10 11:57:10 -06:00
committed by GitHub
parent c3b6ace1b6
commit 9e31597ee4
14 changed files with 51 additions and 41 deletions

View File

@@ -2,6 +2,7 @@ const yaml = require('js-yaml')
const { createChangelogEntry, cleanPreviewTitle, previewAnchor, prependDatedEntry } = require('../../script/graphql/build-changelog')
const fs = require('fs').promises
const MockDate = require('mockdate')
const readFileAsync = require('../../lib/readfile-async')
const expectedChangelogEntry = require('../fixtures/changelog-entry')
const expectedUpdatedChangelogFile = require('../fixtures/updated-changelog-file')
@@ -113,14 +114,14 @@ describe('updating the changelog file', () => {
it('modifies the entry object and the file on disk', async () => {
const testTargetPath = 'tests/graphql/example_changelog.json'
const previousContents = await fs.readFile(testTargetPath)
const previousContents = await readFileAsync(testTargetPath)
const exampleEntry = { someStuff: true }
const expectedDate = '2020-11-20'
MockDate.set(expectedDate)
prependDatedEntry(exampleEntry, testTargetPath)
const newContents = await fs.readFile(testTargetPath, 'utf8')
const newContents = await readFileAsync(testTargetPath, 'utf8')
// reset the file:
await fs.writeFile(testTargetPath, previousContents)