Skip to content

Commit

Permalink
Reading from Github
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Apr 29, 2015
1 parent 53317ae commit fc5360a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"config-multipaas": "^0.1.0",
"restify": "^2.8.3",
"fetch" : "0.3.6",
"js-yaml": "3.3.0"
"js-yaml": "3.3.0",
"nodegit": "0.3.3"
},
"devDependencies": {},
"bundleDependencies": [],
Expand Down
18 changes: 5 additions & 13 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ var cc = require('config-multipaas'),
restify = require('restify'),
fs = require('fs'),
yaml = require('js-yaml'),
fetchUrl = require("fetch").fetchUrl;

fetchUrl = require('fetch').fetchUrl,
Git = require('nodegit');
var config = cc()
.add(
{
"FORGE_WEBSITE_DATA_URL": 'https://github.com/forge/website-data',
"FORGE_WEBSITE_DATA_DIR": (process.env.OPENSHIFT_DATA_DIR || '/tmp') + '/website-data'
"FORGE_WEBSITE_DATA_DIR": (process.env.OPENSHIFT_TMP_DIR || '/tmp') + '/website-data'
}),
app = restify.createServer()

Expand Down Expand Up @@ -102,17 +102,9 @@ function yamlLoad(body) {
}

function gitPullWebsiteData() {
mkdirSync(config.get('FORGE_WEBSITE_DATA_DIR'));
console.log( "Created " + config.get('FORGE_WEBSITE_DATA_DIR') );
}

/* Create a directory, ignoring if already exists */
function mkdirSync(path) {
try {
fs.mkdirSync(path);
} catch(e) {
if ( e.code != 'EEXIST' ) throw e;
}
Git.Clone(config.get('FORGE_WEBSITE_DATA_URL'),config.get('FORGE_WEBSITE_DATA_DIR'))
console.log('Cloned '+config.get('FORGE_WEBSITE_DATA_URL') + ' to ' + config.get('FORGE_WEBSITE_DATA_DIR'))
}

gitPullWebsiteData();

2 comments on commit fc5360a

@lincolnthree
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there really a Node JS Git module? :p

@gastaldi
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but I changed it to execute a native process (git), as it depends on less libraries

Please sign in to comment.