From 1360f9fd9d5e16bad3de615e0b0c0e0d958b5755 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Tue, 10 Apr 2018 18:53:22 -0700 Subject: [PATCH] travis: use a postgres password --- bin/run-mastodon.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/bin/run-mastodon.js b/bin/run-mastodon.js index 178dd45..af48a35 100644 --- a/bin/run-mastodon.js +++ b/bin/run-mastodon.js @@ -18,6 +18,7 @@ const GIT_BRANCH = 'for-pinafore' const DB_NAME = 'pinafore_development' const DB_USER = 'pinafore' +const DB_PASS = 'pinafore' const envFile = ` PAPERCLIP_SECRET=foo @@ -27,6 +28,7 @@ DB_HOST=127.0.0.1 DB_PORT=${process.env.PGPORT || 5432} DB_USER=${DB_USER} DB_NAME=${DB_NAME} +DB_PASS=${DB_PASS} ` const mastodonDir = path.join(dir, '../mastodon') @@ -46,15 +48,24 @@ async function cloneMastodon () { async function setupMastodonDatabase () { console.log('Setting up mastodon database...') try { - await exec(`psql -d template1 -c "CREATE USER ${DB_USER} CREATEDB;"`, {cwd: mastodonDir}) + await exec(`psql -d template1 -c "CREATE USER ${DB_USER} WITH PASSWORD '${DB_PASS}' CREATEDB;"`) } catch (e) { /* ignore */ } try { - await exec(`dropdb -h 127.0.0.1 -U ${DB_USER} -w ${DB_NAME}`, {cwd: mastodonDir}) + await exec(`dropdb -h 127.0.0.1 -U ${DB_USER} -w ${DB_NAME}`, { + cwd: mastodonDir, + env: Object.assign({PGPASSWORD: DB_PASS}, process.env) + }) } catch (e) { /* ignore */ } - await exec(`createdb -h 127.0.0.1 -U ${DB_USER} -w ${DB_NAME}`, {cwd: mastodonDir}) + await exec(`createdb -h 127.0.0.1 -U ${DB_USER} -w ${DB_NAME}`, { + cwd: mastodonDir, + env: Object.assign({PGPASSWORD: DB_PASS}, process.env) + }) let dumpFile = path.join(dir, '../fixtures/dump.sql') - await exec(`psql -h 127.0.0.1 -U ${DB_USER} -w -d ${DB_NAME} -f "${dumpFile}"`, {cwd: mastodonDir}) + await exec(`psql -h 127.0.0.1 -U ${DB_USER} -w -d ${DB_NAME} -f "${dumpFile}"`, { + cwd: mastodonDir, + env: Object.assign({PGPASSWORD: DB_PASS}, process.env) + }) let tgzFile = path.join(dir, '../fixtures/system.tgz') let systemDir = path.join(mastodonDir, 'public/system')