diff --git a/package.json b/package.json index ddbd604..6e99c81 100644 --- a/package.json +++ b/package.json @@ -93,7 +93,6 @@ "eslint-plugin-mocha": "^9.0.0", "eslint-plugin-promise": "^6.0.0", "lint-staged": "^13.0.3", - "fs-extra": "^11.1.0", "mocha": "^10.0.0", "pem": "^1.8.3", "pre-commit": "^1.1.3", diff --git a/test/unit/calendar-specs.js b/test/unit/calendar-specs.js index cbd82c5..273fb88 100644 --- a/test/unit/calendar-specs.js +++ b/test/unit/calendar-specs.js @@ -4,7 +4,7 @@ import chai from 'chai'; import chaiAsPromised from 'chai-as-promised'; import Calendar from '../../lib/calendar'; import { fs } from '@appium/support'; -import { copySync } from 'fs-extra'; +import { copyDir } from '../utils'; import { execSQLiteQuery } from '../../lib/utils'; import path from 'path'; @@ -22,7 +22,7 @@ describe('Calendar.js', function () { beforeEach(async function () { await fs.rimraf(tccDir); - copySync(tccDirOriginal, tccDir); + await copyDir(tccDirOriginal, tccDir); calendar = new Calendar({major: 9}, assetsDir); }); diff --git a/test/unit/certificate-specs.js b/test/unit/certificate-specs.js index 4fb33e8..a3f90ad 100644 --- a/test/unit/certificate-specs.js +++ b/test/unit/certificate-specs.js @@ -4,7 +4,7 @@ import chai from 'chai'; import chaiAsPromised from 'chai-as-promised'; import { Certificate, TrustStore } from '../../lib/certificate'; import { fs, util } from '@appium/support'; -import { copySync } from 'fs-extra'; +import { copyDir } from '../utils'; import path from 'path'; chai.should(); @@ -28,7 +28,7 @@ describe('when using TrustStore class', function () { beforeEach(async function () { keychainsDirOriginal = path.resolve(assetsDir, 'Library', 'Keychains-Original'); await fs.rimraf(keychainsDir); - copySync(keychainsDirOriginal, keychainsDir); + await copyDir(keychainsDirOriginal, keychainsDir); trustStore = new TrustStore(assetsDir); testUUID = getUUID(); }); diff --git a/test/utils.js b/test/utils.js new file mode 100644 index 0000000..b522069 --- /dev/null +++ b/test/utils.js @@ -0,0 +1,16 @@ +import path from 'path'; +import fs from 'fs/promises'; + +export async function copyDir (src, dest) { + const entries = await fs.readdir(src, {withFileTypes: true}); + await fs.mkdir(dest); + for (const entry of entries) { + const srcPath = path.join(src, entry.name); + const destPath = path.join(dest, entry.name); + if (entry.isDirectory()) { + await copyDir(srcPath, destPath); + } else { + await fs.copyFile(srcPath, destPath); + } + } +}