From c6b185cd8fe46f35eefd5536c5bf1a6edebf3115 Mon Sep 17 00:00:00 2001 From: Chen Asraf Date: Sun, 21 Jan 2024 03:22:37 +0200 Subject: [PATCH] feat!: remove url colon syntax --- src/config.ts | 10 ++-------- tests/config.test.ts | 4 ++-- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/config.ts b/src/config.ts index 798acc3..2005e50 100644 --- a/src/config.ts +++ b/src/config.ts @@ -88,14 +88,8 @@ export function parseConfigSelection( key?: string, ): { configFile: string; key: string; isRemote: boolean } { const isUrl = config.includes("://") - - const hasColonToken = (!isUrl && config.includes(":")) || (isUrl && count(config, ":") > 1) - const colonIndex = config.lastIndexOf(":") - const [configFile, templateKey = "default"] = hasColonToken - ? [config.substring(0, colonIndex), config.substring(colonIndex + 1)] - : [config, undefined] - const _key = (key ?? templateKey) || "default" - return { configFile, key: _key, isRemote: isUrl } + const _key = key || "default" + return { configFile: config, key: _key, isRemote: isUrl } } export function githubPartToUrl(part: string): string { diff --git a/tests/config.test.ts b/tests/config.test.ts index dc22130..ca3ec3e 100644 --- a/tests/config.test.ts +++ b/tests/config.test.ts @@ -72,7 +72,7 @@ describe("config", () => { }) }) test("key override", () => { - expect(parseConfigSelection("scaffold.config.js:component", "main")).toEqual({ + expect(parseConfigSelection("scaffold.config.js", "main")).toEqual({ configFile: "scaffold.config.js", key: "main", isRemote: false, @@ -87,7 +87,7 @@ describe("config", () => { }) test("isRemote: true", () => { expect( - parseConfigSelection("https://github.com/chenasraf/simple-scaffold.git#scaffold.config.js:component", "main"), + parseConfigSelection("https://github.com/chenasraf/simple-scaffold.git#scaffold.config.js", "main"), ).toEqual({ configFile: "https://github.com/chenasraf/simple-scaffold.git#scaffold.config.js", key: "main",