diff --git a/bin/now-deploy.js b/bin/now-deploy.js index 0df1a5f..29fc7bb 100755 --- a/bin/now-deploy.js +++ b/bin/now-deploy.js @@ -207,8 +207,11 @@ async function sync(token) { let repo if (isValidRepo && isValidRepo !== 'no-valid-url') { + const gitParts = gitPathParts(rawPath) + Object.assign(gitHubRepo, gitParts) + const searchMessage = setTimeout(() => { - console.log('> Didn\'t find directory. Searching on GitHub...') + console.log(`> Didn\'t find directory. Searching on ${gitHubRepo.type}...`) }, 500) try { @@ -216,9 +219,6 @@ async function sync(token) { } catch (err) {} clearTimeout(searchMessage) - - const gitParts = gitPathParts(rawPath) - Object.assign(gitHubRepo, gitParts) } if (repo) { @@ -229,10 +229,10 @@ async function sync(token) { // once the deployment has finished Object.assign(gitHubRepo, repo) } else if (isValidRepo === 'no-valid-url') { - stopDeployment(`This URL is not a valid repository from GitHub or GitLab.`) + stopDeployment(`This URL is neither a valid repository from GitHub, nor from GitLab.`) } else if (isValidRepo) { const gitRef = gitHubRepo.ref ? `with "${chalk.bold(gitHubRepo.ref)}" ` : '' - stopDeployment(`There's no repository named "${chalk.bold(gitHubRepo.main)}" ${gitRef}on GitHub or GitLab`) + stopDeployment(`There's no repository named "${chalk.bold(gitHubRepo.main)}" ${gitRef}on ${gitHubRepo.type}`) } else { stopDeployment(`Could not read directory ${chalk.bold(path)}`) } @@ -241,7 +241,7 @@ async function sync(token) { if (!quiet) { if (gitHubRepo) { const gitRef = gitHubRepo.ref ? ` at "${chalk.bold(gitHubRepo.ref)}" ` : '' - console.log(`> Deploying GitHub repository "${chalk.bold(gitHubRepo.main)}"` + gitRef) + console.log(`> Deploying ${gitHubRepo.type} repository "${chalk.bold(gitHubRepo.main)}"` + gitRef) } else { console.log(`> Deploying ${chalk.bold(toHumanPath(path))}`) } diff --git a/lib/github.js b/lib/github.js index aed7bdc..cbe5810 100644 --- a/lib/github.js +++ b/lib/github.js @@ -13,7 +13,7 @@ const downloadRepo = async repoPath => { let url switch (pathParts.type) { - case 'gitlab': + case 'GitLab': const ref = pathParts.ref ? `?ref=${pathParts.ref}` : '' url = `https://gitlab.com/${pathParts.main}/repository/archive.tar` + ref break @@ -43,6 +43,10 @@ const downloadRepo = async repoPath => { return tmpDir } +const capitalizePlatform = name => { + return name.replace('github', 'GitHub').replace('gitlab', 'GitLab') +} + const splittedURL = fullURL => { const parsedURL = url.parse(fullURL) const pathParts = parsedURL.path.split('/') @@ -72,7 +76,7 @@ const splittedURL = fullURL => { return { main, ref, - type: parsedURL.host.split('.')[0] + type: capitalizePlatform(parsedURL.host.split('.')[0]) } } @@ -93,7 +97,7 @@ export const gitPathParts = main => { return { main, ref, - type: 'github' + type: capitalizePlatform('github') } }