|
@ -80,5 +80,45 @@ describe('remove', function () { |
|
|
}, 25) |
|
|
}, 25) |
|
|
fse.remove(file) |
|
|
fse.remove(file) |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
it('shouldn’t delete glob matches', function (done) { |
|
|
|
|
|
var 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.') |
|
|
|
|
|
} |
|
|
|
|
|
throw ex |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var wrongFile = path.join(TEST_DIR, 'file1') |
|
|
|
|
|
fs.writeFileSync(wrongFile, 'yo') |
|
|
|
|
|
|
|
|
|
|
|
assert(fs.existsSync(file)) |
|
|
|
|
|
assert(fs.existsSync(wrongFile)) |
|
|
|
|
|
fse.remove(file, function (err) { |
|
|
|
|
|
assert.ifError(err) |
|
|
|
|
|
assert(!fs.existsSync(file)) |
|
|
|
|
|
assert(fs.existsSync(wrongFile)) |
|
|
|
|
|
done() |
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
it('shouldn’t delete glob matches when file doesn’t exist', function (done) { |
|
|
|
|
|
var nonexistentFile = path.join(TEST_DIR, 'file?') |
|
|
|
|
|
|
|
|
|
|
|
var wrongFile = path.join(TEST_DIR, 'file1') |
|
|
|
|
|
fs.writeFileSync(wrongFile, 'yo') |
|
|
|
|
|
|
|
|
|
|
|
assert(!fs.existsSync(nonexistentFile)) |
|
|
|
|
|
assert(fs.existsSync(wrongFile)) |
|
|
|
|
|
fse.remove(nonexistentFile, function (err) { |
|
|
|
|
|
assert.ifError(err) |
|
|
|
|
|
assert(!fs.existsSync(nonexistentFile)) |
|
|
|
|
|
assert(fs.existsSync(wrongFile)) |
|
|
|
|
|
done() |
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|