async function ensureFile(filePath) {
  try {
    // if file exists
    const stat = await Deno.lstat(filePath);
    if (!stat.isFile) {
      throw new Error(
        `Ensure path exists, expected 'file', got '${getFileInfoType(stat)}'`,
      );
    }
  } catch (err) {
    // if file not exists
    if (err instanceof Deno.errors.NotFound) {
      // ensure dir exists
      await ensureDir(path.dirname(filePath));
      // create file
      await Deno.writeFile(filePath, new Uint8Array());
      return;
    }
    throw err;
  }
}
/**
 * Ensures that the file exists.
 * If the file that is requested to be created is in directories that do not
 * exist.
 * these directories are created. If the file already exists,
 * it is NOTMODIFIED.
 * Requires the `--allow-read` and `--allow-write` flag.
 */
Ensures that the file exists.
If the file that is requested to be created is in directories that do not
exist.
these directories are created. If the file already exists,
it is NOTMODIFIED.
Ensures that the file exists . If the file that is requested to be created is in directories that do not exist . these directories are created . If the file already exists it is NOTMODIFIED .
async function ensureFile(filePath) {
  try {
    const stat = await Deno.lstat(filePath);
    if (!stat.isFile) {
      throw new Error(
        `Ensure path exists, expected 'file', got '${getFileInfoType(stat)}'`,
      );
    }
  } catch (err) {
    if (err instanceof Deno.errors.NotFound) {
      await ensureDir(path.dirname(filePath));
      await Deno.writeFile(filePath, new Uint8Array());
      return;
    }
    throw err;
  }
}
async function ensureFile ( filePath ) { try { const stat = await Deno . lstat ( filePath ) ; if ( ! stat . isFile ) { throw new Error ( ` ${ getFileInfoType ( stat ) } ` , ) ; } } catch ( err ) { if ( err instanceof Deno . errors . NotFound ) { await ensureDir ( path . dirname ( filePath ) ) ; await Deno . writeFile ( filePath , new Uint8Array ( ) ) ; return ; } throw err ; } }
Ensures that the file exists.
Ensures that the file exists .
// if file exists // if file not exists // ensure dir exists // create file