Skip to content

Commit 412382b

Browse files
committed
Better typing
1 parent 8cb12fe commit 412382b

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

packages/tools/src/helpers.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,22 @@ export const runAutoFixes = async () => {
110110
return errors;
111111
};
112112

113-
export const getWorkspaces = async (filter?: (workspace: SlugLessWorkspace) => boolean) => {
113+
export const getWorkspaces = async (
114+
filter?: (workspace: SlugLessWorkspace) => boolean,
115+
): Promise<Workspace[]> => {
114116
const { stdout: rawWorkspaces } = await execute('yarn', ['workspaces', 'list', '--json']);
115117
// Replace new lines with commas to make it JSON valid.
116118
const jsonString = `[${rawWorkspaces.replace(/\n([^\]])/g, ',\n$1')}]`;
117119
const workspacesArray = JSON.parse(jsonString) as SlugLessWorkspace[];
118120
return workspacesArray
119121
.filter((workspace: SlugLessWorkspace) => (filter ? filter(workspace) : true))
120-
.map((workspace: SlugLessWorkspace) => ({
121-
...workspace,
122-
slug: workspace.location.split('/').pop() as string,
123-
}));
122+
.map((workspace: SlugLessWorkspace) => {
123+
const plugin: Workspace = {
124+
...workspace,
125+
slug: workspace.location.split('/').pop() as string,
126+
};
127+
return plugin;
128+
});
124129
};
125130

126131
// TODO: Update this, it's a bit hacky.

0 commit comments

Comments
 (0)