diff --git a/cli/jhipster.js b/cli/jhipster.js index 487c17ad4d0b..d5b9cb7748e0 100755 --- a/cli/jhipster.js +++ b/cli/jhipster.js @@ -35,7 +35,7 @@ let preferLocal = true; // Don't use commander for parsing command line to avoid polluting it in cli.js // --prefer-local: Always resolve node modules locally (useful when using linked module) -if (process.argv.includes('upgrade') && !process.argv.includes('--prefer-local')) { +if ((process.argv.includes('upgrade') && !process.argv.includes('--prefer-local')) || process.argv.includes('--prefer-global')) { // Prefer global version for `jhipster upgrade` to get most recent code preferLocal = false; } diff --git a/cli/program.js b/cli/program.js index f497112f0c59..2d77e11e91d4 100644 --- a/cli/program.js +++ b/cli/program.js @@ -54,6 +54,8 @@ const createProgram = () => { .option('--skip-regenerate', "Don't regenerate identical files", false) .option('--skip-yo-resolve', 'Ignore .yo-resolve files', false) .addOption(new Option('--from-jdl', 'Allow every option jdl forwards').default(false).hideHelp()) + .addOption(new Option('--prefer-global', 'Run jhipster installed globally').hideHelp()) + .addOption(new Option('--prefer-local', 'Run jhipster installed locally').hideHelp()) ); }; diff --git a/generators/bootstrap/index.js b/generators/bootstrap/index.js index d40929f7d4f4..7a39d64f9417 100644 --- a/generators/bootstrap/index.js +++ b/generators/bootstrap/index.js @@ -101,7 +101,9 @@ module.exports = class extends BaseGenerator { return; } await this._commitSharedFs(); - this.env.sharedFs.once('change', () => this._queueCommit()); + this.env.sharedFs.once('change', () => { + this._queueCommit(); + }); }, }; } @@ -115,15 +117,18 @@ module.exports = class extends BaseGenerator { */ _queueCommit() { this.debug('Queueing conflicts task'); - this.runLoop.add( - 'conflicts', - (done, stop) => - this._commitSharedFs().then(() => { + this.queueTask( + { + method: async () => { + await this._commitSharedFs(); this.debug('Adding queueCommit event listener'); - this.sharedFs.once('change', () => this.queueCommit); - done(); - }, stop), + this.env.sharedFs.once('change', () => { + this._queueCommit(); + }); + }, + }, { + priorityName: 'conflicts', once: 'write memory fs to disk', } ); diff --git a/generators/entity/index.js b/generators/entity/index.js index 47e94e483ee4..b081afd30b37 100644 --- a/generators/entity/index.js +++ b/generators/entity/index.js @@ -808,17 +808,11 @@ class EntityGenerator extends BaseBlueprintGenerator { // form the data to be passed to modules const context = this.context; - const done = this.async(); // run through all post entity creation module hooks - this.callHooks( - 'entity', - 'post', - { - entityConfig: context, - force: this.options.force, - }, - done - ); + this.callHooks('entity', 'post', { + entityConfig: context, + force: this.options.force, + }); } } catch (err) { this.log(`\n${chalk.bold.red('Running post run module hooks failed. No modification done to the generated entity.')}`); diff --git a/test/bootstrap/bootstrap.spec.js b/test/bootstrap/bootstrap.spec.js new file mode 100644 index 000000000000..bf9693de2553 --- /dev/null +++ b/test/bootstrap/bootstrap.spec.js @@ -0,0 +1,37 @@ +const { dryRunHelpers: helpers } = require('../utils/utils'); +const GeneratorBase = require('../../generators/generator-base'); + +const MockedGenerator = class extends GeneratorBase { + get install() { + return { + writeInstallFile() { + this.writeDestination('installPriority.txt', 'success'); + }, + }; + } + + get end() { + return { + writeEndFile() { + this.writeDestination('endPriority.txt', 'success'); + }, + }; + } +}; + +describe('Bootstrap generator', () => { + context('Default configuration with', () => { + let runResult; + before(async () => { + runResult = await helpers + .create('mocked-generator') + .withGenerators([[MockedGenerator, 'mocked-generator']]) + .withOptions({ defaults: true }) + .run(); + }); + it('should generate files from every priority', () => { + runResult.assertFileContent('installPriority.txt', 'success'); + runResult.assertFileContent('endPriority.txt', 'success'); + }); + }); +}); diff --git a/test/cli/jdl-fork.spec.js b/test/cli/jdl-fork.spec.js index 1bbc95c0e8fd..0cdf2094e8cc 100644 --- a/test/cli/jdl-fork.spec.js +++ b/test/cli/jdl-fork.spec.js @@ -6,7 +6,7 @@ const sinon = require('sinon'); const { prepareTempDir } = require('../utils/utils'); const { runJHipster } = require('../../cli/program'); -describe('jhipster program', () => { +describe('jhipster cli with jdl fork', () => { let cleanup; beforeEach(() => { cleanup = prepareTempDir();