const {spawn} = require('child_process'); const path = require('path'); const dotenv = require('dotenv'); ['.common.env', '.dev.env', '.env'].forEach((filename) => { dotenv.config({path: path.join(__dirname, filename)}); }); const debug = require('debug')('truss:dev'); const {emitObject, emitString} = require('./compose'); const services = process.env.SERVICES.split(','); services.push('gateway'); const composeFile = emitString(emitObject(services)); debug('Compose file:'); debug(composeFile); ['down', 'up'].reduce((promise, op) => { const child = spawn('docker-compose', [ '-f', '-', op, ], { env: process.env, stdio: ['pipe', 'inherit', 'inherit'], }); child.stdin.write(composeFile); return promise.then(() => { child.stdin.end(); return new Promise((resolve) => { child.on('exit', () => { resolve(); }); }); }); }, Promise.resolve());