I try to execute long processes sequentially with node.js (docker exec commands).
I do:
const childProcess = require('child_process');
const execWithPromise = async command => {
    return new Promise(async resolve => {
        const process = childProcess.exec(command);
        process.on('exit', err => resolve(err));
        process.on('close', err => resolve(err));
    });
};
const run = async () => {
    await execWithPromise('/usr/local/bin/docker exec -i -t cucumber node long-running-script.js');
    await execWithPromise('/usr/local/bin/docker exec -i -t cucumber node long-running-script.js');
};
run();
But the promise is resolved immediately with a result of 1. In both cases. The command runs on the commandline just fine.
Why is it returning immediately?
 
     
     
    