/** * * User: Martin Donnelly * Date: 2016-04-04 * Time: 14:46 * */ var exec = require('child_process').exec; function run_script() { 'use strict'; exec('psql -Upostgres -d mdot -h localhost -f ./new.sql', function(err) { if (err !== null) { console.log('exec error: ' + err); return -1; } else { addUsers(); } }); } function prepare_db() { exec('psql -Upostgres -d oBrand -h localhost -f ./obrand.sql', function(err) { if (err !== null) { console.log('exec error: ' + err); return -1; } else { addUsers(); } }); } function createDB() { 'use strict'; exec('createdb -Upostgres -h localhost oBrand', function(err) { if (err !== null) { console.log('exec error: ' + err); return -1; } else { prepare_db(); } }); } // createDB(); run_script();