Skip to content

Commit

Permalink
refactor: use fs.promises
Browse files Browse the repository at this point in the history
  • Loading branch information
dnalborczyk committed Dec 26, 2021
1 parent c2218af commit 66e4420
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions test/watch/index.js
Expand Up @@ -9,7 +9,7 @@ const {
} = require('fs');
const { resolve } = require('path');
const process = require('process');
const { copy, removeSync } = require('fs-extra');
const { copy, remove, removeSync } = require('fs-extra');
const sander = require('sander');
const rollup = require('../../dist/rollup');

Expand All @@ -24,9 +24,9 @@ function wait(ms) {
describe('rollup.watch', () => {
let watcher;

beforeEach(() => {
beforeEach(async () => {
process.chdir(cwd);
return removeSync('test/_tmp');
await remove('test/_tmp');
});

afterEach(() => {
Expand Down Expand Up @@ -345,9 +345,9 @@ describe('rollup.watch', () => {
'END',
async () => {
assert.strictEqual(lastEvent, null);
writeFileSync(WATCHED_ID, 'another');
await promises.writeFile(WATCHED_ID, 'another');
await wait(100);
unlinkSync(WATCHED_ID);
await promises.unlink(WATCHED_ID);
},
'START',
'BUNDLE_START',
Expand All @@ -356,21 +356,21 @@ describe('rollup.watch', () => {
async () => {
assert.strictEqual(lastEvent, 'delete');
lastEvent = null;
writeFileSync(WATCHED_ID, '123');
await promises.writeFile(WATCHED_ID, '123');
await wait(100);
unlinkSync(WATCHED_ID);
await promises.unlink(WATCHED_ID);
// To ensure there is always another change to trigger a rebuild
writeFileSync(MAIN_ID, 'export default 43;');
await promises.writeFile(MAIN_ID, 'export default 43;');
},
'START',
'BUNDLE_START',
'BUNDLE_END',
'END',
async () => {
assert.strictEqual(lastEvent, null);
writeFileSync(WATCHED_ID, '123');
await promises.writeFile(WATCHED_ID, '123');
await wait(100);
writeFileSync(WATCHED_ID, 'asd');
await promises.writeFile(WATCHED_ID, 'asd');
},
'START',
'BUNDLE_START',
Expand Down

0 comments on commit 66e4420

Please sign in to comment.