Skip to content

Commit

Permalink
refactor: Drop usage of fs-extra module (#344)
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach authored Dec 9, 2022
1 parent cc35e3e commit 4c1a63e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions test/unit/calendar-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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);
});

Expand Down
4 changes: 2 additions & 2 deletions test/unit/certificate-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
});
Expand Down
16 changes: 16 additions & 0 deletions test/utils.js
Original file line number Diff line number Diff line change
@@ -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);
}
}
}

0 comments on commit 4c1a63e

Please # to comment.