Skip to content

Commit

Permalink
feat(exec): Exec can also run if the app is not yet started
Browse files Browse the repository at this point in the history
  • Loading branch information
florianPat committed Nov 15, 2024
1 parent 400f751 commit 6f9f747
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions tasks/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ module.exports = (lando, config = lando.appConfig) => ({
ropts.push(sconf?.overrides?.working_dir ?? sconf?.working_dir);
// mix in mount if applicable
ropts.push(app?.mounts[options.service]);
ropts.push(!options.deps ?? true);
ropts.push(options.autoRemove ?? false);

// emit pre-exec
await app.events.emit('pre-exec', config);
Expand All @@ -137,18 +139,12 @@ module.exports = (lando, config = lando.appConfig) => ({
// try to run it
try {
lando.log.debug('running exec command %o on %o', runner.cmd, runner.id);
await require('../utils/build-docker-exec')(lando, ['inherit', 'pipe', 'pipe'], runner);
await lando.engine.run(runner);

// error
} catch (error) {
return lando.engine.isRunning(runner.id).then(isRunning => {
if (!isRunning) {
throw new Error(`Looks like your app is stopped! ${color.bold('lando start')} it up to exec your heart out.`);
} else {
error.hide = true;
throw error;
}
});
error.hide = true;
throw error;

// finally
} finally {
Expand Down

0 comments on commit 6f9f747

Please sign in to comment.