Created
May 3, 2018 05:25
-
-
Save juliantheberge/afbd60429b0f4fad2803ecd61b3e7f72 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// concatinates file names | |
function stringOfFiles(dir:string, array:[string], version:number, rev:boolean) { | |
let finalArr = []; | |
if (rev) { | |
for (let i = array.length-1; i >= version;i--) { | |
finalArr.push("-f " + dir + '/' + array[i]) | |
} | |
return " -a " + finalArr.join(' ') | |
} else { | |
for (let i = 0; i < version;i++) { | |
finalArr.push("-f " + dir + '/' + array[i]) | |
} | |
return " -a " + finalArr.join(' ') | |
} | |
} | |
// this function is called in this section of the db build script | |
... | |
func.filesInDir('./database-builds/up', function(err:Error, files:[string]){ | |
if (err) { | |
console.log(err) | |
} else { | |
let fileString = func.stringOfFiles('./database-builds/up', files, result.version, false); | |
console.log(fileString); | |
func.childProcess(dbConnect + fileString, function(err:Error, stdout:string, stderr:string) { | |
if (err) { | |
console.error(`exec error: ${err}`); | |
cb(err); | |
} else { | |
console.log(`stdout: ${stdout}`); | |
console.log(`stderr: ${stderr}`); | |
console.log('tables added'); | |
func.makeJSONfromObj('./sdist/config/connect-config.json', jsonConfig, function(err:string) { // store that information in a JSON | |
if(err) { | |
console.log(err) | |
cb(err); | |
} else { | |
console.log('successfuly made config JSON') | |
cb(); | |
} | |
}); | |
} | |
}) | |
} | |
}) | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment