diff --git a/scripts/load-perf-config.js b/scripts/load-perf-config.js index 24cb396e93b..647ee9b720f 100644 --- a/scripts/load-perf-config.js +++ b/scripts/load-perf-config.js @@ -1,4 +1,4 @@ -const fs = require('fs'); +const { accessSync, constants } = require('fs'); const path = require('path'); const rollup = require('../dist/rollup.js'); @@ -6,7 +6,7 @@ exports.targetDir = path.resolve(__dirname, '..', 'perf'); const configFile = path.resolve(exports.targetDir, 'rollup.config.js'); try { - fs.accessSync(configFile, fs.constants.R_OK); + accessSync(configFile, constants.R_OK); } catch (e) { console.error( `No valid "rollup.config.js" in ${exports.targetDir}. Did you "npm run perf:init"?` diff --git a/scripts/perf-init.js b/scripts/perf-init.js index 6cd860f73c1..2411e3a8a4e 100644 --- a/scripts/perf-init.js +++ b/scripts/perf-init.js @@ -1,6 +1,6 @@ /* eslint-disable no-console */ -const fs = require('fs'); +const { accessSync, constants } = require('fs'); const path = require('path'); const execa = require('execa'); const sander = require('sander'); @@ -43,7 +43,7 @@ async function setupNewRepo(repo, branch) { gitArgs.push(`https://github.com/${repo}.git`, TARGET_DIR); await execWithOutput('git', gitArgs); try { - fs.accessSync(path.resolve(TARGET_DIR, 'rollup.config.js'), fs.constants.R_OK); + accessSync(path.resolve(TARGET_DIR, 'rollup.config.js'), constants.R_OK); } catch (e) { throw new Error('The repository needs to have a file "rollup.config.js" at the top level.'); } diff --git a/test/hooks/index.js b/test/hooks/index.js index d0f04609ae1..7470e8fe464 100644 --- a/test/hooks/index.js +++ b/test/hooks/index.js @@ -1,4 +1,5 @@ const assert = require('assert'); +const { readdirSync } = require('fs'); const path = require('path'); const sander = require('sander'); const rollup = require('../../dist/rollup.js'); @@ -33,7 +34,7 @@ describe('hooks', () => { }) ) .then(() => { - const fileNames = sander.readdirSync(TEMP_DIR).sort(); + const fileNames = readdirSync(TEMP_DIR).sort(); assert.deepStrictEqual(fileNames, ['chunk.js', 'input.js']); return sander.rimraf(TEMP_DIR); })); diff --git a/test/utils.js b/test/utils.js index ae9be43197a..1c7f5e6ff33 100644 --- a/test/utils.js +++ b/test/utils.js @@ -1,5 +1,5 @@ const assert = require('assert'); -const { unlinkSync } = require('fs'); +const { readdirSync, unlinkSync } = require('fs'); const path = require('path'); const fixturify = require('fixturify'); const sander = require('sander'); @@ -120,8 +120,8 @@ function runSamples(samplesDir, runTest, onTeardown) { if (onTeardown) { afterEach(onTeardown); } - sander - .readdirSync(samplesDir) + + readdirSync(samplesDir) .filter(name => name[0] !== '.') .sort() .forEach(fileName => runTestsInDir(path.join(samplesDir, fileName), runTest)); @@ -146,7 +146,7 @@ function runTestsInDir(dir, runTest) { function getFileNamesAndRemoveOutput(dir) { try { - return sander.readdirSync(dir).filter(fileName => { + return readdirSync(dir).filter(fileName => { if (fileName === '_actual') { sander.rimrafSync(path.join(dir, '_actual')); return false; diff --git a/test/watch/index.js b/test/watch/index.js index c305e13df9e..5fd2e0a8dc2 100644 --- a/test/watch/index.js +++ b/test/watch/index.js @@ -1,5 +1,12 @@ const assert = require('assert'); -const { existsSync, promises, readFileSync, unlinkSync, writeFileSync } = require('fs'); +const { + existsSync, + promises, + readdirSync, + readFileSync, + unlinkSync, + writeFileSync +} = require('fs'); const path = require('path'); const sander = require('sander'); const rollup = require('../../dist/rollup'); @@ -1150,7 +1157,7 @@ describe('rollup.watch', () => { 'BUNDLE_END', 'END', () => { - [dynamicName, staticName, chunkName] = sander.readdirSync('test/_tmp/output').sort(); + [dynamicName, staticName, chunkName] = readdirSync('test/_tmp/output').sort(); sander.rimrafSync('test/_tmp/output'); // this should only update the hash of that particular entry point