Skip to content

Commit

Permalink
feat(daemon): Accept spread path at makeDirectory()
Browse files Browse the repository at this point in the history
  • Loading branch information
rekmarks committed May 15, 2024
1 parent 63a58b1 commit 61dc434
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/cli/src/commands/mkdir.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ import { parsePetNamePath } from '../pet-name.js';

export const mkdir = async ({ agentNames, directoryPath }) =>
withEndoAgent(agentNames, { os, process }, async ({ agent }) => {
await E(agent).makeDirectory(parsePetNamePath(directoryPath));
await E(agent).makeDirectory(...parsePetNamePath(directoryPath));
});
14 changes: 7 additions & 7 deletions packages/daemon/src/directory.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,6 @@ export const makeDirectoryMaker = ({
await toHub.write([toName], id);
};

/** @type {EndoDirectory['makeDirectory']} */
const makeDirectory = async directoryPetName => {
const { value: directory, id } = await formulateDirectory();
await petStore.write(directoryPetName, id);
return directory;
};

/** @type {EndoDirectory['write']} */
const write = async (petNamePath, id) => {
if (typeof petNamePath === 'string') {
Expand All @@ -228,6 +221,13 @@ export const makeDirectoryMaker = ({
await hub.write([name], id);
};

/** @type {EndoDirectory['makeDirectory']} */
const makeDirectory = async (...directoryPetNamePath) => {
const { value: directory, id } = await formulateDirectory();
await write(directoryPetNamePath, id);
return directory;
};

/** @type {EndoDirectory} */
const directory = {
has,
Expand Down
2 changes: 1 addition & 1 deletion packages/daemon/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ export interface NameHub {
}

export interface EndoDirectory extends NameHub {
makeDirectory(petName: string): Promise<EndoDirectory>;
makeDirectory(...petNamePath: string[]): Promise<EndoDirectory>;
}

export type MakeDirectoryNode = (petStore: PetStore) => EndoDirectory;
Expand Down

0 comments on commit 61dc434

Please sign in to comment.