{"version":3,"file":"read-file.mjs","names":["readFileSyncFs","readFileFs"],"sources":["../src/read-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, readFileSync as readFileSyncFs } from \"node:fs\";\nimport { readFile as readFileFs } from \"node:fs/promises\";\n\n/**\n * Read the given content to the given file path\n *\n * @param filePath - The file path to write to\n */\nexport const readFileSync = (filePath: string): string => {\n  if (!filePath) {\n    throw new Error(\"No file path provided to read data\");\n  }\n\n  return readFileSyncFs(filePath, { encoding: \"utf8\" });\n};\n\n/**\n * Read the given content to the given file path\n *\n * @param filePath - The file path to read to\n */\nexport const readFile = async (filePath: string): Promise<string> => {\n  if (!filePath) {\n    throw new Error(\"No file path provided to read data\");\n  }\n\n  return readFileFs(filePath, { encoding: \"utf8\" });\n};\n\n/**\n * Reads a file if it exists, otherwise returns an empty string.\n *\n * @param path - The path to the file to read.\n * @returns The content of the file if it exists, otherwise an empty string.\n */\nexport function readFileIfExistingSync(path: string) {\n  return existsSync(path) ? readFileSync(path) : \"\";\n}\n\n/**\n * Reads a file if it exists, otherwise returns an empty string.\n *\n * @param path - The path to the file to read.\n * @returns The content of the file if it exists, otherwise an empty string.\n */\nexport async function readFileIfExisting(path: string) {\n  return existsSync(path) ? readFile(path) : \"\";\n}\n"],"mappings":";;;;;;;;;AA0BA,MAAa,gBAAgB,aAA6B;AACxD,KAAI,CAAC,SACH,OAAM,IAAI,MAAM,qCAAqC;AAGvD,QAAOA,eAAe,UAAU,EAAE,UAAU,QAAQ,CAAC;;;;;;;AAQvD,MAAa,WAAW,OAAO,aAAsC;AACnE,KAAI,CAAC,SACH,OAAM,IAAI,MAAM,qCAAqC;AAGvD,QAAOC,WAAW,UAAU,EAAE,UAAU,QAAQ,CAAC;;;;;;;;AASnD,SAAgB,uBAAuB,MAAc;AACnD,QAAO,WAAW,KAAK,GAAG,aAAa,KAAK,GAAG;;;;;;;;AASjD,eAAsB,mBAAmB,MAAc;AACrD,QAAO,WAAW,KAAK,GAAG,SAAS,KAAK,GAAG"}