|
@@ -0,0 +1,44 @@
|
|
|
+const { exec,execSync } = require('child_process');
|
|
|
+
|
|
|
+let refreshDelay = 60;
|
|
|
+
|
|
|
+if(process.env.REFRESH_DELAY) refreshDelay = process.env.REFRESH_DELAY;
|
|
|
+
|
|
|
+if(!process.env.REPOSITORY_URL) throw "Env var GIT_REPOSITORY must be a valid repository url";
|
|
|
+
|
|
|
+let cloneUrl = process.env.REPOSITORY_URL;
|
|
|
+if(process.env.REPOSITORY_TOKEN){
|
|
|
+ cloneUrl = cloneUrl.replace(/(.*:\/\/)(.*)/,'$1'+'myProject:'+process.env.REPOSITORY_TOKEN+'@$2');
|
|
|
+}
|
|
|
+
|
|
|
+console.log("starting program");
|
|
|
+console.log("refresh delay is ("+refreshDelay+"s)");
|
|
|
+
|
|
|
+console.log('Cloning doc repository: '+process.env.GIT_REPOSITORY);
|
|
|
+let stdout = execSync('cd /rdoc && git clone '+cloneUrl+" docs");
|
|
|
+console.log(stdout);
|
|
|
+
|
|
|
+setInterval(function() {
|
|
|
+ exec('cd /rdoc/docs && git reset --hard origin/master && git pull', (error, stdout, stderr) => {
|
|
|
+ if (error) {
|
|
|
+ console.error(`error: ${error}`);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(stdout.indexOf('Already up to date')!==-1) return;
|
|
|
+ console.log(`${stdout}`);
|
|
|
+ console.error(`${stderr}`);
|
|
|
+});
|
|
|
+}, refreshDelay * 1000);
|
|
|
+
|
|
|
+console.log("load docsify");
|
|
|
+
|
|
|
+exec('docsify serve /rdoc/docs', (error, stdout, stderr) => {
|
|
|
+ if (error) {
|
|
|
+ console.error(`error: ${error}`);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ console.log(` ${stdout}`);
|
|
|
+ console.error(`${stderr}`);
|
|
|
+});
|
|
|
+
|
|
|
+
|