Skip to content

Commit

Permalink
chore: merged makeDirectories into mkdir
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
aryanjassal committed Oct 1, 2024
1 parent f187d69 commit 3fad8cf
Showing 1 changed file with 1 addition and 36 deletions.
37 changes: 1 addition & 36 deletions src/vaults/VaultOps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,41 +173,7 @@ async function deleteSecret(
* Adds an empty directory to the root of the vault.
* i.e. mkdir("folder", { recursive = false }) creates the "<vaultDir>/folder" directory
*/
async function mkdir(
vault: Vault,
dirPath: string,
fileOptions?: FileOptions,
logger?: Logger,
): Promise<void> {
const recursive = fileOptions?.recursive ?? false;

await vault.writeF(async (efs) => {
try {
await efs.mkdir(dirPath, fileOptions);
} catch (e) {
if (e.code === 'ENOENT' && !recursive) {
throw new vaultsErrors.ErrorVaultsRecursive(
`could not create directory '${dirPath}' without recursive option`,
{ cause: e },
);
}
if (e.code === 'EEXIST') {
throw new vaultsErrors.ErrorSecretsSecretDefined(
`${dirPath} already exists`,
{ cause: e },
);
}
throw e;
}
logger?.info(`Created secret directory at '${dirPath}'`);
});
}

/**
* Adds an empty directory to the root of the vault.
* i.e. mkdir("folder", { recursive = false }) creates the "<vaultDir>/folder" directory
*/
async function* makeDirectories(
async function* mkdir(
vault: Vault,
dirPaths: Array<string>,
fileOptions?: FileOptions,
Expand Down Expand Up @@ -328,7 +294,6 @@ export {
statSecret,
deleteSecret,
mkdir,
makeDirectories,
addSecretDirectory,
listSecrets,
writeSecret,
Expand Down

0 comments on commit 3fad8cf

Please sign in to comment.