test: Remove unnecessary file-exists dependency

Change-Type: patch
This commit is contained in:
Jonas Hermsmeier 2018-02-09 19:45:54 +01:00
parent c3600ee8fc
commit 04352494a0
No known key found for this signature in database
GPG Key ID: 1B870F801A0CEE9F
3 changed files with 9 additions and 11 deletions

5
npm-shrinkwrap.json generated
View File

@ -2512,11 +2512,6 @@
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-2.0.0.tgz",
"dev": true
},
"file-exists": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/file-exists/-/file-exists-1.0.0.tgz",
"dev": true
},
"file-name": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/file-name/-/file-name-0.1.0.tgz",

View File

@ -106,7 +106,6 @@
"eslint-plugin-node": "6.0.0",
"eslint-plugin-promise": "3.6.0",
"eslint-plugin-standard": "3.0.1",
"file-exists": "1.0.0",
"html-angular-validate": "0.1.9",
"mocha": "3.2.0",
"mochainon": "1.0.0",

View File

@ -19,8 +19,7 @@
const m = require('mochainon')
const _ = require('lodash')
const Bluebird = require('bluebird')
const fileExists = require('file-exists')
const fs = Bluebird.promisifyAll(require('fs'))
const fs = require('fs')
const os = require('os')
const path = require('path')
const imageStream = require('../../lib/image-stream/index')
@ -35,9 +34,14 @@ const doFilesContainTheSameData = (file1, file2) => {
}
const deleteIfExists = (file) => {
return Bluebird.try(function () {
if (fileExists(file)) {
return fs.unlinkAsync(file)
return Bluebird.try(() => {
try {
fs.accessSync(file)
fs.unlinkSync(file)
} catch (error) {
if (error.code !== 'ENOENT') {
return Bluebird.reject(error)
}
}
return Bluebird.resolve()