Skip to content

Commit

Permalink
prevent attempting createProjectFromCache when custom blueprint
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelly Selden committed Aug 15, 2019
1 parent 72a81f2 commit 74409da
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"homepage": "https://github.com/ember-cli/ember-cli-update#readme",
"engines": {
"node": ">=8"
"node": ">=8.10"
},
"files": [
"bin",
Expand Down
14 changes: 8 additions & 6 deletions src/get-start-and-end-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ module.exports = function getStartAndEndCommands({
return {
projectName,
projectOptions,
packageName: 'ember-cli',
commandName: 'ember',
// `createProjectFromCache` no longer works with blueprints.
// It will look for an `ember-cli` version with the same
// version as the blueprint.
createProjectFromCache: createProjectFromCache(command),
...projectOptions.includes('blueprint') ? {} : {
packageName: 'ember-cli',
commandName: 'ember',
// `createProjectFromCache` no longer works with blueprints.
// It would look for an `ember-cli` version with the same
// version as the blueprint.
createProjectFromCache: createProjectFromCache(command)
},
createProjectFromRemote: createProjectFromRemote(command),
startOptions: {
packageVersion: startVersion,
Expand Down
57 changes: 41 additions & 16 deletions test/unit/get-start-and-end-commands-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,28 +120,53 @@ describe(_getStartAndEndCommands, function() {
]]);
});

it('can create a project from a custom blueprint', async function() {
let { createProjectFromRemote } = getStartAndEndCommands();
describe('custom blueprint', function() {
it('returns an options object', async function() {
let options = getStartAndEndCommands({
projectOptions: ['blueprint']
});

let createProject = createProjectFromRemote({
options: {
expect(options.createProjectFromRemote).to.be.a('function');

delete options.createProjectFromRemote;

expect(options).to.deep.equal({
projectName,
packageVersion,
blueprint: {
name: blueprint,
path: blueprintPath
projectOptions: ['blueprint'],
startOptions: {
packageVersion: startVersion,
blueprint: { name: 'ember-cli' }
},
endOptions: {
packageVersion: endVersion,
blueprint: { name: 'ember-cli' }
}
}
});
});

expect(await createProject(cwd)).to.equal(projectPath);
it('can create a project from remote', async function() {
let { createProjectFromRemote } = getStartAndEndCommands();

expect(npxStub.args).to.deep.equal([[
`${packageName} new ${projectName} -sn -sg --no-welcome -b ${blueprintPath}`,
{
cwd
}
]]);
let createProject = createProjectFromRemote({
options: {
projectName,
packageVersion,
blueprint: {
name: blueprint,
path: blueprintPath
}
}
});

expect(await createProject(cwd)).to.equal(projectPath);

expect(npxStub.args).to.deep.equal([[
`${packageName} new ${projectName} -sn -sg --no-welcome -b ${blueprintPath}`,
{
cwd
}
]]);
});
});

describe('options', function() {
Expand Down

0 comments on commit 74409da

Please sign in to comment.