From 640446ce255680628b6ae009622b97d56bcaf756 Mon Sep 17 00:00:00 2001 From: Chris Manson Date: Thu, 28 Sep 2023 15:39:47 +0100 Subject: [PATCH] fix projectName if there is no package.json name --- src/get-start-and-end-commands.js | 15 +++++++++++++-- src/index.js | 3 ++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/get-start-and-end-commands.js b/src/get-start-and-end-commands.js index 7bd79188..b5178323 100644 --- a/src/get-start-and-end-commands.js +++ b/src/get-start-and-end-commands.js @@ -23,11 +23,22 @@ const nodeModulesIgnore = ` const lastNode8Version = '3.16'; module.exports = function getStartAndEndCommands({ - packageJson: { name: projectName }, + packageJson, baseBlueprint, startBlueprint, - endBlueprint + endBlueprint, + emberCliUpdateJson }) { + // ember-cli-update.json can override projectName and we should use the name field in package.json if it doesn't exist + let projectName = emberCliUpdateJson.projectName ?? packageJson.name; + + // if we haven't overridden projectName in ember-cli-update or we don't have a name in the package.json file + // default to containing dir name + if (!projectName) { + let pathParts = process.cwd().split(path.sep); + projectName = pathParts[pathParts.length - 1]; + } + if (baseBlueprint && !baseBlueprint.isBaseBlueprint) { throw new Error('The intended base blueprint is not actually a base blueprint.'); } diff --git a/src/index.js b/src/index.js index 6b679ee4..47222dce 100644 --- a/src/index.js +++ b/src/index.js @@ -214,7 +214,8 @@ module.exports = async function emberCliUpdate({ packageJson, baseBlueprint, startBlueprint, - endBlueprint + endBlueprint, + emberCliUpdateJson }); return {