Skip to content

Commit

Permalink
nitpick: template => extension
Browse files Browse the repository at this point in the history
  • Loading branch information
technophile-04 committed Jun 20, 2024
1 parent d42d837 commit 1064ae8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/utils/parse-arguments-into-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,33 @@ import path from "path";
import { fileURLToPath } from "url";

const validateExternalExtension = async (
template: string,
extensionName: string,
dev: boolean,
): Promise<{ repository: string; branch?: string } | string> => {
if (dev) {
// Check that the template folders exists in extensions/${template}
// Check externalExtensions/${extensionName} exists
try {
const currentFileUrl = import.meta.url;
const externalExtensionsDirectory = path.resolve(
decodeURI(fileURLToPath(currentFileUrl)),
"../../externalExtensions",
);
await fs.promises.access(`${externalExtensionsDirectory}/${template}`);
await fs.promises.access(`${externalExtensionsDirectory}/${extensionName}`);
} catch {
throw new Error(`Template not found in "externalExtensions/${template}"`);
throw new Error(`Extesnion not found in "externalExtensions/${extensionName}"`);
}

return template;
return extensionName;
}

const { githubUrl, githubBranchUrl, branch } = getDataFromExternalExtensionArgument(template);
const { githubUrl, githubBranchUrl, branch } = getDataFromExternalExtensionArgument(extensionName);

// Check if repository exists
await new Promise((resolve, reject) => {
https
.get(githubBranchUrl, res => {
if (res.statusCode !== 200) {
reject(new Error(`Template not found: ${githubUrl}`));
reject(new Error(`Extension not found: ${githubUrl}`));
} else {
resolve(null);
}
Expand Down

0 comments on commit 1064ae8

Please sign in to comment.