diff --git a/src/fs.ts b/src/fs.ts index 1059628..82ee297 100644 --- a/src/fs.ts +++ b/src/fs.ts @@ -78,27 +78,3 @@ export async function writeSecureFile( await fs.writeFile(outputPath, data, opts); return outputPath; } - -/** - * removeFile removes the file at the given path. If the file does not exist, it - * does nothing. - * - * @param filePath Path of the file on disk to delete. - * - * @returns A boolean, true if the file was deleted, false otherwise. - * - * @deprecated Use #forceRemove instead. - */ -export async function removeFile(filePath: PathLike): Promise { - try { - await fs.unlink(filePath); - return true; - } catch (err) { - if (isNotFoundError(err)) { - return false; - } - - const msg = errorMessage(err); - throw new Error(`Failed to remove "${filePath}": ${msg}`); - } -} diff --git a/tests/fs.test.ts b/tests/fs.test.ts index da88e75..9f96e7b 100644 --- a/tests/fs.test.ts +++ b/tests/fs.test.ts @@ -23,7 +23,7 @@ import { promises as fs } from 'fs'; import { constants as fsconstants } from 'fs'; import { randomFilepath } from '../src/random'; -import { isEmptyDir, forceRemove, removeFile, writeSecureFile } from '../src/fs'; +import { isEmptyDir, forceRemove, writeSecureFile } from '../src/fs'; describe('fs', { concurrency: true }, async () => { test('#forceRemove', async (suite) => { @@ -74,25 +74,6 @@ describe('fs', { concurrency: true }, async () => { } }); - test('#removeFile', async (suite) => { - await suite.test('deletes the file', async () => { - const filepath = randomFilepath(); - await fs.writeFile(filepath, 'my data'); - const deleted = await removeFile(filepath); - assert.deepStrictEqual(deleted, true); - - await assert.rejects(async () => { - await fs.access(filepath, fsconstants.F_OK); - }, /ENOENT/); - }); - - await suite.test('does nothing when the file does not exist', async () => { - const filepath = '/not/a/file'; - const deleted = await removeFile(filepath); - assert.deepStrictEqual(deleted, false); - }); - }); - test('#writeSecureFile', async (suite) => { await suite.test('writes a file', async () => { const filepath = randomFilepath();