fs/promises#access TypeScript Examples

The following examples show how to use fs/promises#access. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: utils.ts    From rewind with MIT License 7 votes vote down vote up
/**
 * Checks certain files to see if Rewind can be booted without any problems with the given `osuFolderPath`.
 * @param osuFolderPath the folder path to check the files in
 */
export async function osuFolderSanityCheck(osuFolderPath: string) {
  try {
    await Promise.all(filesToCheck.map((f) => access(join(osuFolderPath, f), constants.R_OK)));
  } catch (err) {
    Logger.log(err);
    return false;
  }
  return true;
}
Example #2
Source File: utils.ts    From rewind with MIT License 7 votes vote down vote up
// Just keeping it here just in case
async function createFolderIfNotExisting(folderPath: string) {
  try {
    await access(folderPath, constants.R_OK);
  } catch (err) {
    Logger.log(`Could not access the replays folder '${folderPath}'. Creating a new one`);
    // TODO: Access rights?
    return mkdir(folderPath);
  }
}
Example #3
Source File: generate.ts    From iuliia-js with MIT License 6 votes vote down vote up
async function clone() {
    try {
        await access(join(INPUT_DIR, ".git"));
    } catch (e) {
        const { all: output } = await execa("git", ["clone", SOURCE_REPO, INPUT_DIR], {
            all: true,
        });
        console.log(output);
    }
}