Skip to content

Get questions fail on empty dir #168

@molleweide

Description

@molleweide

I am running boundation on empty dir and an error occurs which I am debugging now.

This question:

		{
			name: 'repoUrl',
			message: 'What will the git URL be?',
			validate: isGitUrl,
			default:
				getRepoUrl(await getGitOriginUrl()) || getPackageRepoUrl(packageData),
		},

fails because getRepoUrl

export function getRepoUrl(input = '') {
        // this is where github-api is called.
        // the github-api func sais it must only recieve type string.
        // >>>> Therefore, there should be a null check here
        // if input then return getRep.. or null
	return getRepositoryUrlFromUrlOrGitHubSlug(input) || null
}

is being supplied null which causes an error in in github-api func:

/Users/hjalmarjakobsson/code/repos/github.com/bevry/boundation/node_modules/@bevry/github-api/source/index.ts

with signature

export function getGitHubSlugFromUrl(url: string): string | null {

when it recieves null:

Specific chunk that fails is:

	// Extract the slug a GitHub URL
	const match = url.match(
		/^(?:github:|git@github[.]com:|(?:(?:git|ssh|https?)[+]?)+:[/][/]github[.]com[/])?([^:/]+[/][^:/]+?)(?:[.]git)?(?:#.*)?$/,
	)

with the error being:

Boundation v1.91.0 [/Users/hjalmarjakobsson/code/repos/github.com/bevry/boundation]
Running on [/Users/hjalmarjakobsson/TEST/boundation_proj_1]
reading the now.json file...
...missing the /Users/hjalmarjakobsson/TEST/boundation_proj_1/now.json file...
reading the vercel.json file...
...missing the /Users/hjalmarjakobsson/TEST/boundation_proj_1/vercel.json file...
getQuestions / getGitOriginUrl: null
getRepoUrl / input: null
getGitHubSlugFromUrl / url: null
TypeError: Cannot read properties of null (reading 'match')
    at getGitHubSlugFromUrl (file:///Users/hjalmarjakobsson/code/repos/github.com/bevry/boundation/node_modules/@bevry/github-api/edition-es2022-esm/index.js:95:23)
    at getRepositoryUrlFromGitHubSlugOrUrl (file:///Users/hjalmarjakobsson/code/repos/github.com/bevry/boundation/node_modules/@bevry/github-api/edition-es2022-esm/index.js:119:20)
    at getRepositoryUrlFromUrlOrGitHubSlug (file:///Users/hjalmarjakobsson/code/repos/github.com/bevry/boundation/node_modules/@bevry/github-api/edition-es2022-esm/index.js:128:12)
    at getRepoUrl (file:///Users/hjalmarjakobsson/code/repos/github.com/bevry/boundation/source/package.js:72:9)
    at getQuestions (file:///Users/hjalmarjakobsson/code/repos/github.com/bevry/boundation/source/questions.js:100:5)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async getAnswers (file:///Users/hjalmarjakobsson/code/repos/github.com/bevry/boundation/source/questions.js:947:3)
    at async init (file:///Users/hjalmarjakobsson/code/repos/github.com/bevry/boundation/source/index.js:22:2)
    at async main (file:///Users/hjalmarjakobsson/code/repos/github.com/bevry/boundation/source/bin.js:33:2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions