Skip to content

Commit

Permalink
feat: try git clone with https after ssh failed
Browse files Browse the repository at this point in the history
  • Loading branch information
3cp committed Mar 13, 2020
1 parent eaa0b71 commit 9f53716
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/skeleton-dir.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ function resolveRepo(supplier) {
if (r) return {
shortcut: r.shortcut(),
tarball: r.tarball(),
git: `git@${r.domain}:${r.user}/${r.project}.git`,
git: r.ssh({noCommittish: true}),
https: r.https({noCommittish: true, noGitPlus: true}),
gitFolder: `${r.domain}-${r.user}-${r.project}`,
committish: r.committish
};
Expand Down
11 changes: 8 additions & 3 deletions lib/use-git-repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const run = require('./run');

// mainly for private skeleton repo.
// Note: no test coverage.
module.exports = async function useGitRepo(folder, {git, gitFolder, committish}) {
module.exports = async function useGitRepo(folder, {git, https, gitFolder, committish}) {
const target = path.join(folder, gitFolder);

if (folderExists(target)) {
Expand All @@ -18,8 +18,13 @@ module.exports = async function useGitRepo(folder, {git, gitFolder, committish})
});
}

info(`Preparing skeleton: git clone ${git} ${gitFolder}`);
await run('git', ['clone', git, gitFolder], folder);
try {
info(`Preparing skeleton: git clone ${git} ${gitFolder}`);
await run('git', ['clone', git, gitFolder], folder);
} catch (err) {
info(`Try https: git clone ${https} ${gitFolder}`);
await run('git', ['clone', https, gitFolder], folder);
}

if (committish && committish !== 'master') {
info(`Preparing skeleton: git checkout ${committish}`);
Expand Down

0 comments on commit 9f53716

Please sign in to comment.