Skip to content

Commit

Permalink
fix(tests): Fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
florianPat committed Mar 5, 2025
1 parent 20f4333 commit 7cd2baf
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
3 changes: 2 additions & 1 deletion examples/cache/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ cat ~/.lando/cache/lando-cache.compose.cache

# Should regenerate the caches on any --help before the help is displayed
lando --clear
lando exec --help | grep service | grep choices | grep web | grep web2 | grep web3 | grep web4
# NOTE(flo): Web is not here as the task bootstrapping runs before the app init, which gets compose services :/
lando exec --help | grep service | grep choices | grep web2 | grep web3 | grep web4
cat ~/.lando/cache/_.tasks.cache
cat ~/.lando/cache/lando-cache.compose.cache

Expand Down
28 changes: 26 additions & 2 deletions tasks/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
const _ = require('lodash');

const {color} = require('listr2');
const fs = require('fs');
const path = require('path');

// @TODO: when we have a file for recipes/compose we can set choices on service

Expand All @@ -23,6 +25,7 @@ module.exports = (lando, config = lando.appConfig) => ({
service: {
describe: 'Runs on this service',
type: 'string',
choices: config?.allServices ?? [],
},
},
options: {
Expand All @@ -32,8 +35,29 @@ module.exports = (lando, config = lando.appConfig) => ({
},
},
run: async options => {
const app = lando.getApp(options._app.root);
await app.init();
// construct a minapp from various places
const minapp = !_.isEmpty(config) ? config : lando.appConfig;

// if no app then we need to throw
if (!fs.existsSync(minapp.composeCache)) {
const app = lando.getApp(options._app.root);
await app.init();
}

// Build a minimal app
const AsyncEvents = require('../lib/events');
const app = lando.cache.get(path.basename(minapp.composeCache));

// augment
app.config = minapp;
app.events = new AsyncEvents(lando.log);

// Load only what we need so we don't pay the appinit penalty
if (!_.isEmpty(_.get(app, 'config.events', []))) {
_.forEach(app.config.events, (cmds, name) => {
app.events.on(name, 9999, async data => await require('../hooks/app-run-events')(app, lando, cmds, data));
});
}

// nice things
const aservices = app.allServices;
Expand Down

0 comments on commit 7cd2baf

Please sign in to comment.