Skip to content

Commit

Permalink
refactor: Use native fs instead of fs-extra and promisify (vercel#13841)
Browse files Browse the repository at this point in the history
**add-comment.js**
`writeFile` is not unique to `fs-extra`. 

**lib/find-page-file.ts**
ref: vercel#12026
  • Loading branch information
matamatanot authored and rokinsky committed Jul 11, 2020
1 parent 945f3b7 commit b40acad
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/actions/next-stats-action/src/add-comment.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const path = require('path')
const fs = require('fs-extra')
const fs = require('fs').promises
const fetch = require('node-fetch')
const prettyMs = require('pretty-ms')
const logger = require('./util/logger')
Expand Down
7 changes: 2 additions & 5 deletions packages/next/server/lib/find-page-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@ import { join, sep as pathSeparator, normalize } from 'path'
import chalk from 'next/dist/compiled/chalk'
import { isWriteable } from '../../build/is-writeable'
import { warn } from '../../build/output/log'
import fs from 'fs'
import { promisify } from 'util'
import { promises } from 'fs'
import { denormalizePagePath } from '../../next-server/server/normalize-page-path'

const readdir = promisify(fs.readdir)

async function isTrueCasePagePath(pagePath: string, pagesDir: string) {
const pageSegments = normalize(pagePath).split(pathSeparator).filter(Boolean)

const segmentExistsPromises = pageSegments.map(async (segment, i) => {
const segmentParentDir = join(pagesDir, ...pageSegments.slice(0, i))
const parentDirEntries = await readdir(segmentParentDir)
const parentDirEntries = await promises.readdir(segmentParentDir)
return parentDirEntries.includes(segment)
})

Expand Down

0 comments on commit b40acad

Please sign in to comment.