From 38fcee35c263768be84fc85f10c3d0d6210d3a38 Mon Sep 17 00:00:00 2001 From: AWolf81 Date: Thu, 30 May 2019 09:31:56 +0200 Subject: [PATCH] fix test for Windows (fs.rmdir throws dir not empty error) --- tests/dataApi/copyFile-test.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/dataApi/copyFile-test.js b/tests/dataApi/copyFile-test.js index 412d510a..533b1354 100644 --- a/tests/dataApi/copyFile-test.js +++ b/tests/dataApi/copyFile-test.js @@ -3,6 +3,9 @@ const copyFile = require('browser/main/lib/dataApi/copyFile') const path = require('path') const fs = require('fs') +const os = require('os') +const execSync = require('child_process').execSync +const removeDirCommand = os.platform() === 'win32' ? 'rmdir /s /q ' : 'rm -rf ' const testFile = 'test.txt' const srcFolder = path.join(__dirname, '🤔') @@ -29,7 +32,7 @@ test('`copyFile` should handle encoded URI on src path', (t) => { test.after((t) => { fs.unlinkSync(srcPath) fs.unlinkSync(dstPath) - fs.rmdirSync(srcFolder) - fs.rmdirSync(dstFolder) + execSync(removeDirCommand + '"' + srcFolder + '"') + execSync(removeDirCommand + '"' + dstFolder + '"') })