Skip to content

Commit

Permalink
feat(core/scope): uses only children names to identify childre; remov…
Browse files Browse the repository at this point in the history
…es matcher from IChild
  • Loading branch information
rafamel committed May 6, 2019
1 parent e46f0bb commit 685d023
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 11 deletions.
5 changes: 1 addition & 4 deletions src/core/scope/children/from-globs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ export default async function getChildrenFromGlobs(
const children = filter(dirs).map((dir) => ({
name: path.parse(dir).name,
// absolute path
directory: path.join(directory, dir),
matcher(name: string) {
return dir.includes(name);
}
directory: path.join(directory, dir)
}));

// Check for name conflicts
Expand Down
5 changes: 1 addition & 4 deletions src/core/scope/children/from-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ export default function getChildrenFromMap(
): IChild[] {
return Object.entries(map).map(([key, value]) => ({
name: key,
directory: absolute({ path: value, cwd: directory }),
matcher(name: string): boolean {
return name === key;
}
directory: absolute({ path: value, cwd: directory })
}));
}
2 changes: 1 addition & 1 deletion src/core/scope/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default async function setScope(

// child scopes
const matches = children
.filter((child) => child.matcher(name))
.filter((child) => child.name.includes(name))
.map((child) => child.directory);

if (matches.length) {
Expand Down
1 change: 0 additions & 1 deletion src/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export interface IScope {
export interface IChild {
name: string;
directory: string;
matcher: (scope: string) => boolean;
}

export interface ITask {
Expand Down
2 changes: 1 addition & 1 deletion src/public/exec/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function stream(

/** @hidden */
function getChild(name: string, children: IChild[]): IChild {
const matches = children.filter((child) => child.matcher(name));
const matches = children.filter((child) => child.name.includes(name));
if (matches.length > 1) throw Error(`Several scopes matched name "${name}"`);
if (matches.length < 1) throw Error(`Scope "${name}" not found`);
return matches[0];
Expand Down

0 comments on commit 685d023

Please sign in to comment.