Skip to content

Commit

Permalink
feat: differentiate between print and key route names
Browse files Browse the repository at this point in the history
  • Loading branch information
rafamel committed Apr 4, 2021
1 parent 2ff3f85 commit 11e8755
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/helpers/parse.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Task } from '../definitions';
import { constants } from '../constants';
import { series } from '../tasks/aggregate/series';
import { stringifyRoute } from './stringify-route';
import { stringifyKeyRoute } from './stringify-route';
import { Members, TypeGuard } from 'type-core';

interface Item {
Expand Down Expand Up @@ -56,7 +56,7 @@ export function parseToArray(

return parseHelper(record, options.roots)
.map(([route, task]) => {
const name = stringifyRoute(route);
const name = stringifyKeyRoute(route);

if (names.includes(name)) {
throw Error(`Task name collusion on parse: ${name}`);
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/prefix.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Context } from '../definitions';
import { styleString } from './style-string';
import { stringifyRoute } from './stringify-route';
import { stringifyPrintRoute } from './stringify-route';
import { into } from 'pipettes';
import { TypeGuard } from 'type-core';

Expand All @@ -11,7 +11,7 @@ export function getPrefix(
): string {
return into(
{
prefix: context.route.length ? stringifyRoute(context.route) : '',
prefix: context.route.length ? stringifyPrintRoute(context.route) : '',
policy: TypeGuard.isString(context.prefix)
? context.prefix
: context.prefix
Expand Down
8 changes: 7 additions & 1 deletion src/helpers/stringify-route.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
export function stringifyRoute(route: string[]): string {
import { constants } from '../constants';

export function stringifyPrintRoute(route: string[]): string {
return route.filter((str) => str !== constants.record.default).join(':');
}

export function stringifyKeyRoute(route: string[]): string {
return route.join(':');
}

0 comments on commit 11e8755

Please sign in to comment.