Replace 'require' with 'import' in bench files and update dependancies (#25775)

## Feature

- [ ] Telemetry added. In case of a feature if it's used or not.

### Replace 'require' with 'import' in bench files
Node.js 12 allows you to use `import`.

### Update dependancies
https://github.com/jprichardson/node-fs-extra/blob/master/CHANGELOG.md#breaking-changes

> Require Node.js v12+

For #25761, Node.js 12 is required. Therefore, there is no problem updating it. For benchmarking purposes, it would be reasonable to update to the latest version.
This commit is contained in:
matamatanot 2021-06-04 23:30:52 +09:00 committed by GitHub
parent dfc5907f10
commit c922c6a3f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 27 additions and 29 deletions

View file

@ -1,5 +1,5 @@
const http = require('http')
const fs = require('fs')
import { createServer } from 'http'
import { writeFileSync } from 'fs'
const PORT = 9411
const HOST = '0.0.0.0'
@ -53,11 +53,11 @@ const main = () => {
process.on('SIGINT', () => {
console.log(`\nSaving to ${outFile}...`)
fs.writeFileSync(outFile, JSON.stringify(traces, null, 2))
writeFileSync(outFile, JSON.stringify(traces, null, 2))
process.exit()
})
const server = http.createServer(onRequest)
const server = createServer(onRequest)
server.listen(PORT, HOST, onReady)
}

View file

@ -8,7 +8,7 @@
"bench:recursive-copy": "node recursive-copy/run"
},
"dependencies": {
"fs-extra": "7.0.1",
"recursive-copy": "2.0.10"
"fs-extra": "10.0.0",
"recursive-copy": "2.0.11"
}
}

View file

@ -1,6 +1,7 @@
const { join } = require('path')
const { promisify } = require('util')
const globMod = require('glob')
import { join } from 'path'
import { promisify } from 'util'
import globMod from 'glob'
const glob = promisify(globMod)
const resolveDataDir = join(__dirname, 'fixtures', '**/*')

View file

@ -1,5 +1,5 @@
const { join } = require('path')
const { recursiveReadDir } = require('next/dist/lib/recursive-readdir')
import { join } from 'path'
import { recursiveReadDir } from 'next/dist/lib/recursive-readdir'
const resolveDataDir = join(__dirname, 'fixtures')
async function test() {

View file

@ -1,18 +1,14 @@
const { join } = require('path')
const fs = require('fs-extra')
const recursiveCopyNpm = require('recursive-copy')
const {
recursiveCopy: recursiveCopyCustom,
} = require('next/dist/lib/recursive-copy')
import { join } from 'path'
import { ensureDir, outputFile, remove } from 'fs-extra'
import recursiveCopyNpm from 'recursive-copy'
import { recursiveCopy as recursiveCopyCustom } from 'next/dist/lib/recursive-copy'
const fixturesDir = join(__dirname, 'fixtures')
const srcDir = join(fixturesDir, 'src')
const destDir = join(fixturesDir, 'dest')
const createSrcFolder = async () => {
await fs.ensureDir(srcDir)
await ensureDir(srcDir)
const files = new Array(100)
.fill(undefined)
@ -20,7 +16,7 @@ const createSrcFolder = async () => {
join(srcDir, `folder${i % 5}`, `folder${i + (1 % 5)}`, `file${i}`)
)
await Promise.all(files.map((file) => fs.outputFile(file, 'hello')))
await Promise.all(files.map((file) => outputFile(file, 'hello')))
}
async function run(fn) {
@ -38,7 +34,7 @@ async function run(fn) {
for (let i = 0; i < 10; i++) {
const t = await test()
await fs.remove(destDir)
await remove(destDir)
ts.push(t)
}
@ -57,7 +53,7 @@ async function main() {
console.log('test recursive-copy custom implementation')
await run(recursiveCopyCustom)
await fs.remove(fixturesDir)
await remove(fixturesDir)
}
main()

View file

@ -1,5 +1,5 @@
const { join } = require('path')
const { recursiveDelete } = require('next/dist/lib/recursive-delete')
import { join } from 'path'
import { recursiveDelete } from 'next/dist/lib/recursive-delete'
const resolveDataDir = join(__dirname, `fixtures-${process.argv[2]}`)
async function test() {

View file

@ -1,8 +1,9 @@
const { join } = require('path')
const { promisify } = require('util')
const rimrafMod = require('rimraf')
const resolveDataDir = join(__dirname, `fixtures-${process.argv[2]}`, '**/*')
import { join } from 'path'
import { promisify } from 'util'
import rimrafMod from 'rimraf'
const rimraf = promisify(rimrafMod)
const resolveDataDir = join(__dirname, `fixtures-${process.argv[2]}`, '**/*')
async function test() {
const time = process.hrtime()