From fdd3da60986ece65beaa408d7c19b725f0f3ee6c Mon Sep 17 00:00:00 2001 From: Julien Bouquillon Date: Fri, 13 Jan 2023 10:11:48 +0100 Subject: [PATCH] wip --- packages/common/utils/async-shell.js | 2 +- packages/common/utils/degit-tag-has-changed.js | 11 +++++++++++ packages/common/utils/parse-command.js | 5 +++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/common/utils/async-shell.js b/packages/common/utils/async-shell.js index 2383c1a928..18ca926f96 100644 --- a/packages/common/utils/async-shell.js +++ b/packages/common/utils/async-shell.js @@ -50,7 +50,7 @@ const promiseFromChildProcess = (child, callback, logger, extraOptions) => { } /** * - * @param {[cmd: string, args: string[]]} arg + * @param {string} arg * @param {Record} options * @param {null | ((child: import("child_process").ChildProcessWithoutNullStreams) => void)} callback * @param {Kontinuous.PatchContext["logger"]} logger diff --git a/packages/common/utils/degit-tag-has-changed.js b/packages/common/utils/degit-tag-has-changed.js index 9a438cd46e..6f9b23bbaf 100644 --- a/packages/common/utils/degit-tag-has-changed.js +++ b/packages/common/utils/degit-tag-has-changed.js @@ -6,6 +6,7 @@ const asyncShell = require("./async-shell") const normalizeRepositoryUrl = require("./normalize-repository-url") +/** @type {Record} */ const supported = { github: ".com", gitlab: ".com", @@ -14,6 +15,11 @@ const supported = { "git.sr.ht": ".ht", } +/** + * + * @param {string} src + * @returns {{site:string, user:string, name:string, ref:string, url:string, ssh:string, subdir:string, mode:string}} + */ function parse(src) { const match = /^(?:(?:https:\/\/)?([^:/]+\.[^:/]+)\/|git@([^:/]+)[:/]|([^/]+):)?([^/\s]+)\/([^/\s#]+)(?:((?:\/[^/\s#]+)+))?(?:\/)?(?:#(.+))?/.exec( @@ -45,6 +51,11 @@ function parse(src) { return { site: siteName, user, name, ref, url, ssh, subdir, mode } } +/** + * + * @param {string} target + * @returns boolean + */ module.exports = async (target) => { const base = path.join(os.homedir(), ".degit") const repo = parse(target) diff --git a/packages/common/utils/parse-command.js b/packages/common/utils/parse-command.js index cbca40d01d..406bfd2000 100644 --- a/packages/common/utils/parse-command.js +++ b/packages/common/utils/parse-command.js @@ -1,3 +1,8 @@ +/** + * + * @param {string|string[]} arg + * @returns {[cmd: string, args:string[]]} + */ module.exports = (arg) => { if (typeof arg === "string") { arg = arg