From cedc0dd7fcb62d06fbcbee6310a4db1752d6c691 Mon Sep 17 00:00:00 2001 From: Kelly Selden Date: Thu, 15 Aug 2019 10:58:15 +0100 Subject: [PATCH] prevent attempting `createProjectFromCache` when custom blueprint --- package.json | 2 +- src/get-start-and-end-commands.js | 14 ++--- test/unit/get-start-and-end-commands-test.js | 57 ++++++++++++++------ 3 files changed, 50 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index a5dcbaf36..966519112 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ }, "homepage": "https://github.com/ember-cli/ember-cli-update#readme", "engines": { - "node": ">=8" + "node": ">=8.10" }, "files": [ "bin", diff --git a/src/get-start-and-end-commands.js b/src/get-start-and-end-commands.js index 4f4f4272c..2b5bbe021 100644 --- a/src/get-start-and-end-commands.js +++ b/src/get-start-and-end-commands.js @@ -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, diff --git a/test/unit/get-start-and-end-commands-test.js b/test/unit/get-start-and-end-commands-test.js index ef109ef85..e26b71e6f 100644 --- a/test/unit/get-start-and-end-commands-test.js +++ b/test/unit/get-start-and-end-commands-test.js @@ -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() {