diff --git a/lib/remove/__tests__/remove-dir.test.js b/lib/remove/__tests__/remove-dir.test.js index 0b0f5be6..6edec0cd 100644 --- a/lib/remove/__tests__/remove-dir.test.js +++ b/lib/remove/__tests__/remove-dir.test.js @@ -1,24 +1,26 @@ -var assert = require('assert') -var fs = require('fs') -var path = require('path') -var os = require('os') -var fse = require(process.cwd()) +'use strict' + +const fs = require('fs') +const os = require('os') +const fse = require(process.cwd()) +const path = require('path') +const assert = require('assert') /* global beforeEach, describe, it */ -describe('remove / async / dir', function () { - var TEST_DIR +describe('remove / async / dir', () => { + let TEST_DIR - beforeEach(function (done) { + beforeEach(done => { TEST_DIR = path.join(os.tmpdir(), 'fs-extra', 'remove-async-dir') fse.emptyDir(TEST_DIR, done) }) - describe('> when dir does not exist', function () { - it('should not throw an error', function (done) { - var someDir = path.join(TEST_DIR, 'some-dir/') + describe('> when dir does not exist', () => { + it('should not throw an error', done => { + const someDir = path.join(TEST_DIR, 'some-dir/') assert.equal(fs.existsSync(someDir), false) - fse.remove(someDir, function (err) { + fse.remove(someDir, err => { assert.ifError(err) done() }) diff --git a/lib/remove/__tests__/remove-sync-dir.test.js b/lib/remove/__tests__/remove-sync-dir.test.js index 7469039b..5372bd66 100644 --- a/lib/remove/__tests__/remove-sync-dir.test.js +++ b/lib/remove/__tests__/remove-sync-dir.test.js @@ -1,28 +1,30 @@ -var assert = require('assert') -var fs = require('fs') -var os = require('os') -var path = require('path') -var fse = require(process.cwd()) +'use strict' + +const fs = require('fs') +const os = require('os') +const fse = require(process.cwd()) +const path = require('path') +const assert = require('assert') /* global beforeEach, describe, it */ -describe('remove/sync', function () { - var TEST_DIR +describe('remove/sync', () => { + let TEST_DIR - beforeEach(function (done) { + beforeEach(done => { TEST_DIR = path.join(os.tmpdir(), 'fs-extra', 'remove-sync') fse.emptyDir(TEST_DIR, done) }) - describe('+ removeSync()', function () { - it('should delete directories and files synchronously', function () { + describe('+ removeSync()', () => { + it('should delete directories and files synchronously', () => { assert(fs.existsSync(TEST_DIR)) fs.writeFileSync(path.join(TEST_DIR, 'somefile'), 'somedata') fse.removeSync(TEST_DIR) assert(!fs.existsSync(TEST_DIR)) }) - it('should delete an empty directory synchronously', function () { + it('should delete an empty directory synchronously', () => { assert(fs.existsSync(TEST_DIR)) fse.removeSync(TEST_DIR) assert(!fs.existsSync(TEST_DIR)) diff --git a/lib/remove/__tests__/remove-sync-file.test.js b/lib/remove/__tests__/remove-sync-file.test.js index 5a4bed72..68a22966 100644 --- a/lib/remove/__tests__/remove-sync-file.test.js +++ b/lib/remove/__tests__/remove-sync-file.test.js @@ -1,22 +1,24 @@ -var assert = require('assert') -var fs = require('fs') -var os = require('os') -var path = require('path') -var fse = require(process.cwd()) +'use strict' + +const fs = require('fs') +const os = require('os') +const fse = require(process.cwd()) +const path = require('path') +const assert = require('assert') /* global beforeEach, describe, it */ -describe('remove/sync', function () { - var TEST_DIR +describe('remove/sync', () => { + let TEST_DIR - beforeEach(function (done) { + beforeEach(done => { TEST_DIR = path.join(os.tmpdir(), 'fs-extra', 'remove-sync') fse.emptyDir(TEST_DIR, done) }) - describe('+ removeSync()', function () { - it('should delete a file synchronously', function () { - var file = path.join(TEST_DIR, 'file') + describe('+ removeSync()', () => { + it('should delete a file synchronously', () => { + const file = path.join(TEST_DIR, 'file') fs.writeFileSync(file, 'hello') assert(fs.existsSync(file)) fse.removeSync(file) diff --git a/lib/remove/__tests__/remove.test.js b/lib/remove/__tests__/remove.test.js index bf4d5deb..d7c2fbdf 100644 --- a/lib/remove/__tests__/remove.test.js +++ b/lib/remove/__tests__/remove.test.js @@ -1,77 +1,77 @@ -var assert = require('assert') -var fs = require('fs') -var os = require('os') -var path = require('path') -var sr = require('secure-random') -var fse = require(process.cwd()) +'use strict' + +const assert = require('assert') +const fs = require('fs') +const os = require('os') +const path = require('path') +const sr = require('secure-random') +const fse = require(process.cwd()) /* global afterEach, beforeEach, describe, it */ -var TEST_DIR +let TEST_DIR function buildFixtureDir () { - var buf = sr.randomBuffer(5) - var baseDir = path.join(TEST_DIR, 'TEST_fs-extra_remove-' + Date.now()) + const buf = sr.randomBuffer(5) + const baseDir = path.join(TEST_DIR, `TEST_fs-extra_remove-${Date.now()}`) fs.mkdirSync(baseDir) fs.writeFileSync(path.join(baseDir, Math.random() + ''), buf) fs.writeFileSync(path.join(baseDir, Math.random() + ''), buf) - var subDir = path.join(TEST_DIR, Math.random() + '') + const subDir = path.join(TEST_DIR, Math.random() + '') fs.mkdirSync(subDir) fs.writeFileSync(path.join(subDir, Math.random() + '')) return baseDir } -describe('remove', function () { - beforeEach(function (done) { +describe('remove', () => { + beforeEach(done => { TEST_DIR = path.join(os.tmpdir(), 'fs-extra', 'remove') fse.emptyDir(TEST_DIR, done) }) - afterEach(function (done) { - fse.remove(TEST_DIR, done) - }) + afterEach(done => fse.remove(TEST_DIR, done)) - describe('+ remove()', function () { - it('should delete an empty directory', function (done) { + describe('+ remove()', () => { + it('should delete an empty directory', done => { assert(fs.existsSync(TEST_DIR)) - fse.remove(TEST_DIR, function (err) { + fse.remove(TEST_DIR, err => { assert.ifError(err) assert(!fs.existsSync(TEST_DIR)) done() }) }) - it('should delete a directory full of directories and files', function (done) { + it('should delete a directory full of directories and files', done => { buildFixtureDir() assert(fs.existsSync(TEST_DIR)) - fse.remove(TEST_DIR, function (err) { + fse.remove(TEST_DIR, err => { assert.ifError(err) assert(!fs.existsSync(TEST_DIR)) done() }) }) - it('should delete a file', function (done) { - var file = path.join(TEST_DIR, 'file') + it('should delete a file', done => { + const file = path.join(TEST_DIR, 'file') fs.writeFileSync(file, 'hello') assert(fs.existsSync(file)) - fse.remove(file, function (err) { + fse.remove(file, err => { assert.ifError(err) assert(!fs.existsSync(file)) done() }) }) - it('should delete without a callback', function (done) { - var file = path.join(TEST_DIR, 'file') + it('should delete without a callback', done => { + const file = path.join(TEST_DIR, 'file') fs.writeFileSync(file, 'hello') assert(fs.existsSync(file)) - var existsChecker = setInterval(function () { - fs.exists(file, function (itDoes) { + const existsChecker = setInterval(() => { + fs.exists(file, (itDoes) => { if (!itDoes) { clearInterval(existsChecker) done() @@ -82,22 +82,20 @@ describe('remove', function () { }) it('shouldn’t delete glob matches', function (done) { - var file = path.join(TEST_DIR, 'file?') + const file = path.join(TEST_DIR, 'file?') try { fs.writeFileSync(file, 'hello') } catch (ex) { - if (ex.code === 'ENOENT') { - return this.skip('Windows does not support filenames with ‘?’ or ‘*’ in them.') - } + if (ex.code === 'ENOENT') return this.skip('Windows does not support filenames with ‘?’ or ‘*’ in them.') throw ex } - var wrongFile = path.join(TEST_DIR, 'file1') + const wrongFile = path.join(TEST_DIR, 'file1') fs.writeFileSync(wrongFile, 'yo') assert(fs.existsSync(file)) assert(fs.existsSync(wrongFile)) - fse.remove(file, function (err) { + fse.remove(file, err => { assert.ifError(err) assert(!fs.existsSync(file)) assert(fs.existsSync(wrongFile)) @@ -105,15 +103,15 @@ describe('remove', function () { }) }) - it('shouldn’t delete glob matches when file doesn’t exist', function (done) { - var nonexistentFile = path.join(TEST_DIR, 'file?') + it('shouldn’t delete glob matches when file doesn’t exist', done => { + const nonexistentFile = path.join(TEST_DIR, 'file?') - var wrongFile = path.join(TEST_DIR, 'file1') + const wrongFile = path.join(TEST_DIR, 'file1') fs.writeFileSync(wrongFile, 'yo') assert(!fs.existsSync(nonexistentFile)) assert(fs.existsSync(wrongFile)) - fse.remove(nonexistentFile, function (err) { + fse.remove(nonexistentFile, err => { assert.ifError(err) assert(!fs.existsSync(nonexistentFile)) assert(fs.existsSync(wrongFile))