Skip to content

Commit

Permalink
Fix looking up the default blueprint for scoped addons
Browse files Browse the repository at this point in the history
Closes #10090
  • Loading branch information
GendelfLugansk authored and bertdeblock committed Jan 27, 2023
1 parent 1e415ad commit 2eebb4b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
23 changes: 6 additions & 17 deletions lib/models/blueprint.js
Expand Up @@ -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;
Expand All @@ -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}`);
}
Expand Down
6 changes: 6 additions & 0 deletions tests/acceptance/addon-generate-test.js
Expand Up @@ -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']);
});
});

0 comments on commit 2eebb4b

Please sign in to comment.