Skip to content

Commit

Permalink
testing: update runCli to use EnvironmentBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Sep 26, 2024
1 parent 9d3daaf commit 50b731a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/testing/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,14 +469,16 @@ class JHipsterTest extends YeomanTest {

runCli(command: string | string[]): JHipsterRunContext {
// Use a dummy generator which will not be used to match yeoman-test requirement.
return this.run(this.createDummyGenerator(), { namespace: 'non-used-dummy:generator' }).withEnvironmentRun(async function (this, env) {
// Customize program to throw an error instead of exiting the process on cli parse error.
const program = createProgram().exitOverride();
await buildJHipster({ program, env: env as any, silent: true });
await program.parseAsync(['jhipster', 'jhipster', ...(Array.isArray(command) ? command : command.split(' '))]);
// Put the rootGenerator in context to be used in result assertions.
this.generator = env.rootGenerator();
});
return this.run(this.createDummyGenerator(), { namespace: 'non-used-dummy:generator' })
.withJHipsterGenerators({ useEnvironmentBuilder: true })
.withEnvironmentRun(async function (this, env) {
// Customize program to throw an error instead of exiting the process on cli parse error.
const program = createProgram().exitOverride();
await buildJHipster({ program, env: env as any, silent: true });
await program.parseAsync(['jhipster', 'jhipster', ...(Array.isArray(command) ? command : command.split(' '))]);
// Put the rootGenerator in context to be used in result assertions.
this.generator = env.rootGenerator();
});
}

/**
Expand Down

0 comments on commit 50b731a

Please sign in to comment.