From 2eebb4b8d060c420f8113c3fef4a243048212d60 Mon Sep 17 00:00:00 2001 From: Gennady Dogaev Date: Fri, 2 Dec 2022 18:43:47 +0200 Subject: [PATCH] Fix looking up the default blueprint for scoped addons Closes #10090 --- lib/models/blueprint.js | 23 ++++++----------------- tests/acceptance/addon-generate-test.js | 6 ++++++ 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/lib/models/blueprint.js b/lib/models/blueprint.js index 356a6a112af..d259c7ad433 100644 --- a/lib/models/blueprint.js +++ b/lib/models/blueprint.js @@ -1508,23 +1508,6 @@ let Blueprint = CoreObject.extend({ Blueprint.lookup = function (name, options) { options = options || {}; - if (name.includes(path.sep)) { - let blueprintPath = path.resolve(name); - let isNameAPath = Boolean(blueprintPath); - - if (isNameAPath) { - if (Blueprint._existsSync(blueprintPath)) { - return Blueprint.load(blueprintPath, options.blueprintOptions); - } - - if (!options.ignoreMissing) { - throw new SilentError(`Unknown blueprint: ${name}`); - } - - return; - } - } - let lookupPaths = generateLookupPaths(options.paths); let lookupPath; @@ -1536,6 +1519,12 @@ Blueprint.lookup = function (name, options) { } } + // Check if `name` itself is a path to a blueprint: + let blueprintPath = path.resolve(name); + if (Blueprint._existsSync(blueprintPath)) { + return Blueprint.load(blueprintPath, options.blueprintOptions); + } + if (!options.ignoreMissing) { throw new SilentError(`Unknown blueprint: ${name}`); } diff --git a/tests/acceptance/addon-generate-test.js b/tests/acceptance/addon-generate-test.js index 45414e51150..79bfaead3a2 100644 --- a/tests/acceptance/addon-generate-test.js +++ b/tests/acceptance/addon-generate-test.js @@ -143,4 +143,10 @@ describe('Acceptance: ember generate in-addon', function () { await generateInAddon(['server']); expect(file('server/index.js')).to.exist; }); + + it('successfully generates the default blueprint for scoped addons', async function () { + await initAddon('@foo/bar'); + await ember(['g', 'blueprint', '@foo/bar']); + await ember(['g', '@foo/bar', 'baz']); + }); });