UNPKG

@stryke/fs

Version:

A package containing various file system utilities that expand the functionality of NodeJs's built-in `fs` module.

1 lines 1.74 kB
{"version":3,"file":"remove-file.mjs","names":[],"sources":["../src/remove-file.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { existsSync, rmSync } from \"node:fs\";\nimport { rm } from \"node:fs/promises\";\n\n/**\n * Remove the given content to the given file path\n *\n * @param filePath - The file path to remove to\n */\nexport const removeFileSync = (filePath: string): void => {\n if (!filePath || !existsSync(filePath)) {\n return;\n }\n\n rmSync(filePath);\n};\n\n/**\n * Remove the given content to the given file path\n *\n * @param filePath - The file path to read to\n */\nexport const removeFile = async (filePath: string): Promise<void> => {\n if (!filePath || !existsSync(filePath)) {\n return;\n }\n\n return rm(filePath);\n};\n"],"mappings":";;;;;;;;;AA0BA,MAAa,kBAAkB,aAA2B;AACxD,KAAI,CAAC,YAAY,CAAC,WAAW,SAAS,CACpC;AAGF,QAAO,SAAS;;;;;;;AAQlB,MAAa,aAAa,OAAO,aAAoC;AACnE,KAAI,CAAC,YAAY,CAAC,WAAW,SAAS,CACpC;AAGF,QAAO,GAAG,SAAS"}