From b711aa475f3b9ac86ff7e8e9c0697ec53c76dfd5 Mon Sep 17 00:00:00 2001 From: JrMasterModelBuilder Date: Sat, 30 Sep 2023 01:49:52 -0400 Subject: [PATCH] Code cleanup --- src/mounter.test.ts | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/mounter.test.ts b/src/mounter.test.ts index 73e4c44..dd202f6 100644 --- a/src/mounter.test.ts +++ b/src/mounter.test.ts @@ -1,15 +1,11 @@ /* eslint-disable max-nested-callbacks */ import {describe, it} from 'node:test'; import {deepStrictEqual, ok, strictEqual} from 'node:assert'; -import {lstat, readdir} from 'node:fs'; -import {promisify} from 'node:util'; +import {lstat, readdir} from 'node:fs/promises'; import {platform, release} from 'node:os'; import {Mounter} from './mounter'; -const readdirP = promisify(readdir); -const lstatP = promisify(lstat); - const fixtures = './spec/fixtures'; const darwin = platform() === 'darwin'; @@ -30,17 +26,8 @@ const fixtureTestDiskImages = [ .filter(s => s.length) .map(s => `${fixtures}/${s}`); -async function dirlist(path: string, dotfiles = true) { - const r = await readdirP(path); - return r.filter(s => (s.startsWith('.') ? dotfiles : true)).sort(); -} - -async function stat(path: string) { - try { - return await lstatP(path); - } catch (err) { - return null; - } +async function dirlist(path: string) { + return (await readdir(path)).filter(s => !s.startsWith('.')).sort(); } class MounterTestRun extends Mounter { @@ -230,7 +217,9 @@ void describe('mounter', () => { } if (mountPoint) { - const st = await stat(mountPoint); + const st = await lstat(mountPoint).catch( + () => null + ); strictEqual(st, null); } });