Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

github.com 이외의 저장소 사용 가능하도록 수정 #316

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 67 additions & 7 deletions bin/gh-pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,25 @@ console.log('"'+'[email protected]:[github-id]/[github-id].github.com.git'.red +'"'
rl.question(' > ', function(repo) {

var user, regx, branch, project;
var isGithub = true;

if(repo.indexOf('https') >= 0) {
regx = /github.com\/([^\/]+)/;
if (repo.indexOf('github') >= 0) {
if(repo.indexOf('https') >= 0) {
regx = /github.com\/([^\/]+)/;
} else {
regx = /:([^\/]+)/;
}
user = repo.match(regx)[1];
branch = (repo.match(/\/[\w-]+.github.com/) == null) ? 'gh-pages' : 'master';
project = (branch == 'gh-pages') ? repo.match(/\/([^\.]+)/)[1] : '';
} else {
regx = /:([^\/]+)/;
isGithub = false;
}
user = repo.match(regx)[1];
branch = (repo.match(/\/[\w-]+.github.com/) == null) ? 'gh-pages' : 'master';
project = (branch == 'gh-pages') ? repo.match(/\/([^\.]+)/)[1] : '';

console.log('haroo> git remote -v¶'.yellow);
exec('git remote -v', function(code, stdout, stderr) {
console.log(stdout);
if (stdout.match(/origin.+?\/haroopress/) != null) {
if (isGithub && stdout.match(/origin.+?\/haroopress/) != null) {
step(
function gitInit() {
console.log('haroo> Start setting github pages branch ¶'.yellow);
Expand Down Expand Up @@ -123,6 +128,61 @@ rl.question(' > ', function(repo) {
console.log('haroo> completed'.cyan);
}
);
} else { // for other repository
step(
function gitInit(code, stdout, stderr) {
console.log('haroo> Start setting github pages branch ¶'.yellow);
exec('git init', this);
},
function gitRemoteAdd(code, stdout, stderr) {
console.log(stdout);
console.log('haroo> Git remote add to origin ¶'.red);
exec('git remote add origin '+ repo, this)
},
function gitPull(code, stdout, stderr) {
console.log(stdout);
console.log('haroo > Trying git pull from remote ¶'.yellow);
exec('git pull origin master', this);
},
function gitPullResult(code, stdout, stderr) {
console.log(stdout);
if (stderr.indexOf('FATAL:') >= 0) {
step(
function setGitConfig(code, stdout, stderr) {
console.log(stdout);
console.log('haroo> Added remote %s as origin ¶'.yellow, repo);
exec('git config branch.master.remote origin', this);
},
function initHaroog(code, stdout, stderr) {
console.log(stdout);
console.log('haroo> Created inex.html ¶'.yellow);
exec('echo "<!-- haroopress init -->" > index.html', this);
},
function gitAdd(code, stdout, stderr) {
console.log(stdout);
console.log('haroo> git add . ¶'.yellow);
exec('git add .', this);
},
function gitCommit(code, stdout, stderr) {
console.log(stdout);
console.log('haroo> git commit -m "init site" ¶'.yellow);
exec('git commit -m "init site"', this);
},
function gitPush(code, stdout, stderr) {
console.log(stdout);
console.log('haroo> git push origin master ¶'.yellow)
exec('git push origin master', this);
},
function end(code, stdout, stderr) {
console.log(stdout);
console.log('haroo> completed'.cyan);
}
);
} else {
console.log('haroo> completed'.cyan);
}
}
);
}
});

Expand Down