Skip to content

Commit

Permalink
chore: cleanup according to comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pmmmwh committed Jul 11, 2024
1 parent 6b52365 commit 6223872
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
4 changes: 2 additions & 2 deletions benchmark.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';
import Benchmark from 'benchmark';
import {makeDirectorySync} from 'make-dir';
import {temporaryDirectory} from 'tempy';
import {deleteAsync, deleteSync} from './index.js';

Expand All @@ -13,7 +13,7 @@ const fixtures = Array.from({length: 2000}, (_, index) => path.resolve(temporary

function createFixtures() {
for (const fixture of fixtures) {
makeDirectorySync(path.resolve(temporaryDirectoryPath, fixture));
fs.mkdirSync(path.resolve(temporaryDirectoryPath, fixture), {recursive: true});
}
}

Expand Down
6 changes: 0 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,12 @@
"devDependencies": {
"ava": "^6.1.3",
"benchmark": "^2.1.4",
"make-dir": "^5.0.0",
"tempy": "^3.1.0",
"tsd": "^0.31.0",
"xo": "^0.58.0"
},
"ava": {
"serial": true,
"workerThreads": false
},
"xo": {
"rules": {
"unicorn/prefer-string-replace-all": "off"
}
}
}
13 changes: 6 additions & 7 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import path from 'node:path';
import process from 'node:process';
import test from 'ava';
import {temporaryDirectory} from 'tempy';
import {makeDirectorySync} from 'make-dir';
import {deleteAsync, deleteSync} from './index.js';

const __dirname = path.dirname(fileURLToPath(import.meta.url));
Expand Down Expand Up @@ -34,7 +33,7 @@ test.beforeEach(t => {
t.context.tmp = temporaryDirectory();

for (const fixture of fixtures) {
makeDirectorySync(path.join(t.context.tmp, fixture));
fs.mkdirSync(path.join(t.context.tmp, fixture), {recursive: true});
}
});

Expand Down Expand Up @@ -125,7 +124,7 @@ test('does not throw EINVAL - async', async t => {

let count = 0;
while (count !== totalAttempts) {
makeDirectorySync(nestedFile);
fs.mkdirSync(nestedFile, {recursive: true});

// eslint-disable-next-line no-await-in-loop
const removed = await deleteAsync('**/*', {
Expand Down Expand Up @@ -160,7 +159,7 @@ test('does not throw EINVAL - sync', t => {

let count = 0;
while (count !== totalAttempts) {
makeDirectorySync(nestedFile);
fs.mkdirSync(nestedFile, {recursive: true});

const removed = deleteSync('**/*', {
cwd: t.context.tmp,
Expand Down Expand Up @@ -337,7 +336,7 @@ test('windows can pass absolute paths with "\\" - sync', t => {

test('windows can pass relative paths with "\\" - async', async t => {
const nestedFile = path.resolve(t.context.tmp, 'a/b/c/nested.js');
makeDirectorySync(nestedFile);
fs.mkdirSync(nestedFile, {recursive: true});

const removeFiles = await deleteAsync([nestedFile], {cwd: t.context.tmp, dryRun: true});

Expand All @@ -346,7 +345,7 @@ test('windows can pass relative paths with "\\" - async', async t => {

test('windows can pass relative paths with "\\" - sync', t => {
const nestedFile = path.resolve(t.context.tmp, 'a/b/c/nested.js');
makeDirectorySync(nestedFile);
fs.mkdirSync(nestedFile, {recursive: true});

const removeFiles = deleteSync([nestedFile], {cwd: t.context.tmp, dryRun: true});

Expand Down Expand Up @@ -389,7 +388,7 @@ test('onProgress option - progress of single file', async t => {
test('onProgress option - progress of multiple files', async t => {
const reports = [];

const sourcePath = process.platform === 'win32' ? path.resolve(`${t.context.tmp}/*`).replace(/\\/g, '/') : `${t.context.tmp}/*`;
const sourcePath = process.platform === 'win32' ? path.resolve(`${t.context.tmp}/*`).replaceAll('\\', '/') : `${t.context.tmp}/*`;

await deleteAsync(sourcePath, {
cwd: __dirname,
Expand Down

0 comments on commit 6223872

Please sign in to comment.