Skip to content

Commit 7908eb9

Browse files
committed
Remove deprecated removeFile method
1 parent f442333 commit 7908eb9

2 files changed

Lines changed: 1 addition & 44 deletions

File tree

src/fs.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -78,27 +78,3 @@ export async function writeSecureFile<T extends PathLike>(
7878
await fs.writeFile(outputPath, data, opts);
7979
return outputPath;
8080
}
81-
82-
/**
83-
* removeFile removes the file at the given path. If the file does not exist, it
84-
* does nothing.
85-
*
86-
* @param filePath Path of the file on disk to delete.
87-
*
88-
* @returns A boolean, true if the file was deleted, false otherwise.
89-
*
90-
* @deprecated Use #forceRemove instead.
91-
*/
92-
export async function removeFile(filePath: PathLike): Promise<boolean> {
93-
try {
94-
await fs.unlink(filePath);
95-
return true;
96-
} catch (err) {
97-
if (isNotFoundError(err)) {
98-
return false;
99-
}
100-
101-
const msg = errorMessage(err);
102-
throw new Error(`Failed to remove "${filePath}": ${msg}`);
103-
}
104-
}

tests/fs.test.ts

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { promises as fs } from 'fs';
2323
import { constants as fsconstants } from 'fs';
2424
import { randomFilepath } from '../src/random';
2525

26-
import { isEmptyDir, forceRemove, removeFile, writeSecureFile } from '../src/fs';
26+
import { isEmptyDir, forceRemove, writeSecureFile } from '../src/fs';
2727

2828
describe('fs', { concurrency: true }, async () => {
2929
test('#forceRemove', async (suite) => {
@@ -74,25 +74,6 @@ describe('fs', { concurrency: true }, async () => {
7474
}
7575
});
7676

77-
test('#removeFile', async (suite) => {
78-
await suite.test('deletes the file', async () => {
79-
const filepath = randomFilepath();
80-
await fs.writeFile(filepath, 'my data');
81-
const deleted = await removeFile(filepath);
82-
assert.deepStrictEqual(deleted, true);
83-
84-
await assert.rejects(async () => {
85-
await fs.access(filepath, fsconstants.F_OK);
86-
}, /ENOENT/);
87-
});
88-
89-
await suite.test('does nothing when the file does not exist', async () => {
90-
const filepath = '/not/a/file';
91-
const deleted = await removeFile(filepath);
92-
assert.deepStrictEqual(deleted, false);
93-
});
94-
});
95-
9677
test('#writeSecureFile', async (suite) => {
9778
await suite.test('writes a file', async () => {
9879
const filepath = randomFilepath();

0 commit comments

Comments
 (0)