diff --git a/package.json b/package.json index fc402a1..b2f2001 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ }, "devDependencies": { "fs-extra": "^0.12.0", - "mocha": "*" + "mocha": "*", + "path-exists": "^1.0.0" } } diff --git a/test.js b/test.js index cd79fce..60155e9 100644 --- a/test.js +++ b/test.js @@ -1,6 +1,7 @@ 'use strict'; var assert = require('assert'); var fs = require('fs-extra'); +var pathExists = require('path-exists'); var del = require('./'); beforeEach(function () { @@ -26,50 +27,50 @@ afterEach(function () { it('should delete files - async', function (cb) { del(['*.tmp', '!1*'], function (err) { assert(!err, err); - assert(fs.existsSync('1.tmp')); - assert(!fs.existsSync('2.tmp')); - assert(!fs.existsSync('3.tmp')); - assert(!fs.existsSync('4.tmp')); - assert(fs.existsSync('.dot.tmp')); + assert(pathExists.sync('1.tmp')); + assert(!pathExists.sync('2.tmp')); + assert(!pathExists.sync('3.tmp')); + assert(!pathExists.sync('4.tmp')); + assert(pathExists.sync('.dot.tmp')); cb(); }); }); it('should delete files - sync', function () { del.sync(['*.tmp', '!1*']); - assert(fs.existsSync('1.tmp')); - assert(!fs.existsSync('2.tmp')); - assert(!fs.existsSync('3.tmp')); - assert(!fs.existsSync('4.tmp')); - assert(fs.existsSync('.dot.tmp')); + assert(pathExists.sync('1.tmp')); + assert(!pathExists.sync('2.tmp')); + assert(!pathExists.sync('3.tmp')); + assert(!pathExists.sync('4.tmp')); + assert(pathExists.sync('.dot.tmp')); }); it('should take account of options - async', function (cb) { del(['*.tmp', '!1*'], {dot: true}, function (err) { assert(!err, err); - assert(fs.existsSync('1.tmp')); - assert(!fs.existsSync('2.tmp')); - assert(!fs.existsSync('3.tmp')); - assert(!fs.existsSync('4.tmp')); - assert(!fs.existsSync('.dot.tmp')); + assert(pathExists.sync('1.tmp')); + assert(!pathExists.sync('2.tmp')); + assert(!pathExists.sync('3.tmp')); + assert(!pathExists.sync('4.tmp')); + assert(!pathExists.sync('.dot.tmp')); cb(); }); }); it('should take account of options - sync', function () { del.sync(['*.tmp', '!1*'], {dot: true}); - assert(fs.existsSync('1.tmp')); - assert(!fs.existsSync('2.tmp')); - assert(!fs.existsSync('3.tmp')); - assert(!fs.existsSync('4.tmp')); - assert(!fs.existsSync('.dot.tmp')); + assert(pathExists.sync('1.tmp')); + assert(!pathExists.sync('2.tmp')); + assert(!pathExists.sync('3.tmp')); + assert(!pathExists.sync('4.tmp')); + assert(!pathExists.sync('.dot.tmp')); }); it('cwd option - sync', function () { var f = 'tmp/tmp.txt'; fs.ensureFileSync(f); del.sync('tmp.txt', {cwd: 'tmp'}); - assert(!fs.existsSync(f)); + assert(!pathExists.sync(f)); fs.remove(f); }); @@ -79,7 +80,7 @@ it('cwd option - async', function (cb) { del('tmp.txt', {cwd: 'tmp'}, function (err) { assert(!err, err); - assert(!fs.existsSync(f)); + assert(!pathExists.sync(f)); fs.remove(f); cb(); });