summaryrefslogtreecommitdiffstats
path: root/lib/parse
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2014-08-08 18:50:07 -0700
committerSamy Pessé <samypesse@gmail.com>2014-08-11 07:36:46 -0700
commit78c68c7b9efd98139182c88580186d2456b1bec7 (patch)
tree3a68e5ca30987f0a9190b5140ff58e416e7dc829 /lib/parse
parentd914eae40a9730d76295750ac47ebed9fe4f7146 (diff)
downloadgitbook-78c68c7b9efd98139182c88580186d2456b1bec7.zip
gitbook-78c68c7b9efd98139182c88580186d2456b1bec7.tar.gz
gitbook-78c68c7b9efd98139182c88580186d2456b1bec7.tar.bz2
Remove config for github urls
Diffstat (limited to 'lib/parse')
-rw-r--r--lib/parse/git.js56
-rw-r--r--lib/parse/index.js3
2 files changed, 1 insertions, 58 deletions
diff --git a/lib/parse/git.js b/lib/parse/git.js
deleted file mode 100644
index 18a7cd3..0000000
--- a/lib/parse/git.js
+++ /dev/null
@@ -1,56 +0,0 @@
-var Q = require('q');
-var _ = require('lodash');
-var cp = require('child_process');
-var url = require('url');
-
-// Get the remote of a given repo
-function gitURL(path) {
- var d = Q.defer();
-
- cp.exec("git config --get remote.origin.url", {
- cwd: path,
- env: process.env,
- }, function(err, stdout, stderr) {
- if(err) {
- return d.reject(err);
- }
-
- return d.resolve(stdout);
- });
-
- return d.promise
- .then(function(output) {
- return output.replace(/(\r\n|\n|\r)/gm, "");
- });
-}
-
-// Poorman's parsing
-// Parse a git URL to a github ID : username/reponame
-function githubID(_url) {
- // Remove .git if it's in _url
- var sliceEnd = _url.slice(-4) === '.git' ? -4 : undefined;
-
- // Detect HTTPS repos
- var parsed = url.parse(_url);
- if(parsed.protocol === 'https:' && parsed.host === 'github.com') {
- return parsed.path.slice(1, sliceEnd);
- }
-
- // Detect SSH repos
- if(_url.indexOf('git@') === 0) {
- return _url.split(':', 2)[1].slice(0, sliceEnd);
- }
-
- // None found
- return null;
-}
-
-function titleCase(str) {
- return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
-}
-
-module.exports = {
- url: gitURL,
- githubID: githubID,
- titleCase: titleCase
-};
diff --git a/lib/parse/index.js b/lib/parse/index.js
index bb7779f..0ebb03a 100644
--- a/lib/parse/index.js
+++ b/lib/parse/index.js
@@ -5,6 +5,5 @@ module.exports = {
lex: require('./lex'),
progress: require('./progress'),
navigation: require('./navigation'),
- readme: require('./readme'),
- git: require('./git')
+ readme: require('./readme')
};