From ab026b1635e21fa416faa92b8bcfa0d1be5317b4 Mon Sep 17 00:00:00 2001 From: Jonas Hermsmeier Date: Mon, 12 Feb 2018 14:42:05 +0100 Subject: [PATCH] test(image-stream): Fix lint error in tester --- tests/image-stream/tester.js | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/tests/image-stream/tester.js b/tests/image-stream/tester.js index 14eba877..f243d25e 100644 --- a/tests/image-stream/tester.js +++ b/tests/image-stream/tester.js @@ -19,7 +19,7 @@ const m = require('mochainon') const _ = require('lodash') const Bluebird = require('bluebird') -const fs = require('fs') +const fs = Bluebird.promisifyAll(require('fs')) const os = require('os') const path = require('path') const imageStream = require('../../lib/image-stream/index') @@ -33,21 +33,6 @@ const doFilesContainTheSameData = (file1, file2) => { }) } -const deleteIfExists = (file) => { - return new Bluebird((resolve, reject) => { - try { - fs.accessSync(file) - fs.unlinkSync(file) - } catch (error) { - if (error.code !== 'ENOENT') { - return reject(error) - } - } - - resolve() - }) -} - exports.DEFAULT_IMAGE_TESTS_TIMEOUT = 20000 exports.expectError = function (file, errorMessage, errorDetail) { @@ -93,7 +78,8 @@ exports.extractFromFilePath = function (file, image) { }).then(function (areEqual) { m.chai.expect(areEqual).to.be.true }).finally(function () { - return deleteIfExists(output) + return fs.unlinkAsync(output) + .catch({ code: 'ENOENT' }, _.noop) }) }) }