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