Skip to content

Commit

Permalink
docs(ensureDirectoryAccess): 📝 update JSDoc for ensureDirectoryAccess
Browse files Browse the repository at this point in the history
- Provide more accurate and detailed information about its purpose and behavior.
  • Loading branch information
navin-moorthy committed Jul 12, 2023
1 parent 4a70a83 commit 69ac9a5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/utils/ensureDirectoryAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ import { throwError } from "./throwError.js";
* Checks if a directory exists and is readable and writable. If it doesn't exist, it creates it. If it exists but is not readable or writable, it makes it both.
* @async
* @function
* @param {string} directoryPath - The path of the directory to check.
* @returns {Promise<void>} A promise that resolves to a void indicating whether the directory exists and is readable and writable.
* @param {string} directoryPath - The directory path to check.
* @returns {Promise<void>} A promise that resolves to a void indicating whether the directory exists and is readable and writable.
* @throws {Error} If the directory does not exist or is not accessible.
*/
export async function ensureDirectoryAccess(
directoryPath: string,
directoryPath: string
): Promise<void> {
try {
await fs.access(
directoryPath,
// eslint-disable-next-line no-bitwise
fsSync.constants.F_OK | fsSync.constants.W_OK | fsSync.constants.R_OK,
fsSync.constants.F_OK | fsSync.constants.W_OK | fsSync.constants.R_OK
);
} catch {
try {
Expand All @@ -26,7 +27,7 @@ export async function ensureDirectoryAccess(
} catch (error) {
throwError(
error,
`${directoryPath} does not exists / writable / readable in ensureDirectoryAccess function`,
`${directoryPath} does not exists / writable / readable in ensureDirectoryAccess function`
);
}
}
Expand Down

0 comments on commit 69ac9a5

Please sign in to comment.