Skip to content

Commit

Permalink
allow to ignore 'This Generator is empty' error
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Jul 31, 2023
1 parent 454b3ec commit 5291e9c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/actions/lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export abstract class TasksMixin {
// Queues map: generator's queue name => grouped-queue's queue name (custom name)
readonly _queues!: Record<string, Priority>;

customLifecycle?: boolean;
runningState?: { namespace: string; queueName: string; methodName: string };
_taskStatus?: TaskStatus;

Expand Down Expand Up @@ -247,7 +248,7 @@ export abstract class TasksMixin {
this._taskStatus = { cancelled: false, timestamp: new Date() };

const validMethods = this.getTaskNames();
if (validMethods.length === 0 && this._prompts.length === 0) {
if (validMethods.length === 0 && this._prompts.length === 0 && !this.customLifecycle) {
throw new Error('This Generator is empty. Add at least one method for it to run.');
}

Expand Down
11 changes: 11 additions & 0 deletions test/base.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,17 @@ describe('Base', () => {
});
});

it("doesn't throw if no method is available with customLifecycle", async function () {
const gen = new (class extends Base {})([], {
resolved: 'generator-ember/all/index.js',
namespace: 'dummy',
env,
});
gen.customLifecycle = true;

await gen.run();
});

it('will run non-enumerable methods', async function () {
class Generator extends Base {}

Expand Down

0 comments on commit 5291e9c

Please sign in to comment.