From 0b440a82a3fa6022c2bdf7deab18fe8e6f855999 Mon Sep 17 00:00:00 2001 From: Daniel Nalborczyk Date: Sat, 25 Dec 2021 22:19:32 -0500 Subject: [PATCH] refactor: use fs-extra.existsSync --- test/cli/index.js | 7 ++----- test/form/index.js | 5 ++--- test/watch/index.js | 24 ++++++++++++------------ 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/test/cli/index.js b/test/cli/index.js index f0c1de862d4..ddbd7c933a0 100644 --- a/test/cli/index.js +++ b/test/cli/index.js @@ -1,7 +1,7 @@ const assert = require('assert'); const { exec } = require('child_process'); const path = require('path'); -const { readFileSync } = require('fs-extra'); +const { existsSync, readFileSync } = require('fs-extra'); const sander = require('sander'); const { normaliseOutput, @@ -99,10 +99,7 @@ runTestSuiteWithSamples( } catch (err) { done(err); } - } else if ( - sander.existsSync('_expected') && - sander.statSync('_expected').isDirectory() - ) { + } else if (existsSync('_expected') && sander.statSync('_expected').isDirectory()) { try { assertDirectoriesAreEqual('_actual', '_expected'); done(); diff --git a/test/form/index.js b/test/form/index.js index 1054aed4655..470d2a0fd38 100644 --- a/test/form/index.js +++ b/test/form/index.js @@ -1,14 +1,13 @@ const assert = require('assert'); const path = require('path'); -const { readFileSync } = require('fs-extra'); -const sander = require('sander'); +const { existsSync, readFileSync } = require('fs-extra'); const rollup = require('../../dist/rollup'); const { normaliseOutput, runTestSuiteWithSamples } = require('../utils.js'); const FORMATS = ['amd', 'cjs', 'system', 'es', 'iife', 'umd']; runTestSuiteWithSamples('form', path.resolve(__dirname, 'samples'), (dir, config) => { - const isSingleFormatTest = sander.existsSync(dir + '/_expected.js'); + const isSingleFormatTest = existsSync(dir + '/_expected.js'); const itOrDescribe = isSingleFormatTest ? it : describe; (config.skip ? itOrDescribe.skip : config.solo ? itOrDescribe.only : itOrDescribe)( path.basename(dir) + ': ' + config.description, diff --git a/test/watch/index.js b/test/watch/index.js index 081be97f222..ccedc70fe52 100644 --- a/test/watch/index.js +++ b/test/watch/index.js @@ -1,6 +1,6 @@ const assert = require('assert'); const path = require('path'); -const { readFileSync } = require('fs-extra'); +const { existsSync, readFileSync } = require('fs-extra'); const sander = require('sander'); const rollup = require('../../dist/rollup'); @@ -572,7 +572,7 @@ describe('rollup.watch', () => { 'BUNDLE_START', 'ERROR', () => { - assert.strictEqual(sander.existsSync('../_tmp/output/bundle.js'), false); + assert.strictEqual(existsSync('../_tmp/output/bundle.js'), false); sander.writeFileSync('test/_tmp/input/main.js', 'export default 43;'); }, 'START', @@ -613,7 +613,7 @@ describe('rollup.watch', () => { 'BUNDLE_START', 'ERROR', () => { - assert.strictEqual(sander.existsSync('../_tmp/output/bundle.js'), false); + assert.strictEqual(existsSync('../_tmp/output/bundle.js'), false); sander.writeFileSync('test/_tmp/input/main.js', 'export default 43;'); }, 'START', @@ -1048,11 +1048,11 @@ describe('rollup.watch', () => { 'END', () => { assert.strictEqual( - sander.existsSync(path.resolve(__dirname, '../_tmp/output/bundle1.js')), + existsSync(path.resolve(__dirname, '../_tmp/output/bundle1.js')), false ); assert.strictEqual( - sander.existsSync(path.resolve(__dirname, '../_tmp/output/bundle2.js')), + existsSync(path.resolve(__dirname, '../_tmp/output/bundle2.js')), true ); assert.deepStrictEqual(run('../_tmp/output/bundle2.js'), 43); @@ -1275,7 +1275,7 @@ describe('rollup.watch', () => { 'END', () => { watchChangeCnt = 0; - assert.strictEqual(sander.existsSync('../_tmp/output/bundle.js'), false); + assert.strictEqual(existsSync('../_tmp/output/bundle.js'), false); sander.writeFileSync('test/_tmp/input/main.js', 'export default 43;'); }, 'START', @@ -1283,7 +1283,7 @@ describe('rollup.watch', () => { 'BUNDLE_END', 'END', () => { - assert.strictEqual(sander.existsSync('../_tmp/output/bundle.js'), false); + assert.strictEqual(existsSync('../_tmp/output/bundle.js'), false); assert.strictEqual(watchChangeCnt, 1); sander.writeFileSync('test/_tmp/input/main.js', 'export default 43;'); }, @@ -1292,7 +1292,7 @@ describe('rollup.watch', () => { 'BUNDLE_END', 'END', () => { - assert.strictEqual(sander.existsSync('../_tmp/output/bundle.js'), false); + assert.strictEqual(existsSync('../_tmp/output/bundle.js'), false); assert.strictEqual(watchChangeCnt, 2); sander.writeFileSync('test/_tmp/input/main.js', 'export default 43;'); }, @@ -1301,7 +1301,7 @@ describe('rollup.watch', () => { 'BUNDLE_END', // 'END', evt => { - assert.strictEqual(sander.existsSync('../_tmp/output/bundle.js'), false); + assert.strictEqual(existsSync('../_tmp/output/bundle.js'), false); assert.strictEqual(watchChangeCnt, 3); // still aware of its output destination assert.strictEqual(evt.output[0], path.resolve('test/_tmp/output/bundle.js')); @@ -1658,7 +1658,7 @@ describe('rollup.watch', () => { plugins: { transform() { this.addWatchFile('test/_tmp/input'); - return `export default ${sander.existsSync(WATCHED_ID)}`; + return `export default ${existsSync(WATCHED_ID)}`; } } }); @@ -1699,7 +1699,7 @@ describe('rollup.watch', () => { plugins: { transform() { this.addWatchFile('test/_tmp/input/dep'); - return `export default ${sander.existsSync('test/_tmp/input/dep')}`; + return `export default ${existsSync('test/_tmp/input/dep')}`; } } }); @@ -1740,7 +1740,7 @@ describe('rollup.watch', () => { plugins: { transform() { this.addWatchFile('test/_tmp/input/dep'); - return `export default ${sander.existsSync('test/_tmp/input/dep')}`; + return `export default ${existsSync('test/_tmp/input/dep')}`; } } });