From 91265aee7880a4d375d58792822573b31c90f864 Mon Sep 17 00:00:00 2001 From: gtmnayan <50981692+gtm-nayan@users.noreply.github.com> Date: Thu, 22 Jun 2023 21:05:52 +0545 Subject: [PATCH] fix: handle missing fields in migrate script (#10221) --- .changeset/tame-boats-attend.md | 5 +++++ packages/migrate/migrations/svelte-4/migrate.js | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 .changeset/tame-boats-attend.md diff --git a/.changeset/tame-boats-attend.md b/.changeset/tame-boats-attend.md new file mode 100644 index 000000000000..55d564c6c0b2 --- /dev/null +++ b/.changeset/tame-boats-attend.md @@ -0,0 +1,5 @@ +--- +'svelte-migrate': patch +--- + +fix: handle missing fields in migrate script diff --git a/packages/migrate/migrations/svelte-4/migrate.js b/packages/migrate/migrations/svelte-4/migrate.js index 200fd5332fc7..f36395a038ee 100644 --- a/packages/migrate/migrations/svelte-4/migrate.js +++ b/packages/migrate/migrations/svelte-4/migrate.js @@ -21,12 +21,12 @@ export function update_pkg_json_content(content) { * @param {string} [additional] */ function update_pkg(name, version, additional = '') { - if (pkg.dependencies[name]) { - log_migration(`Updated ${name} to ${version}${additional}`); + if (pkg.dependencies?.[name]) { + log_migration(`Updated ${name} to ${version} ${additional}`); pkg.dependencies[name] = version; } - if (pkg.devDependencies[name]) { - log_migration(`Updated ${name} to ${version}${additional}`); + if (pkg.devDependencies?.[name]) { + log_migration(`Updated ${name} to ${version} ${additional}`); pkg.devDependencies[name] = version; } }