diff --git a/src/Migrations.ts b/src/Migrations.ts index 0a9e84be..62bf1899 100644 --- a/src/Migrations.ts +++ b/src/Migrations.ts @@ -3,8 +3,8 @@ import {newShellCommandConfiguration, ShellCommandConfiguration} from "./setting export async function RunMigrations(plugin: ShellCommandsPlugin) { let save = MigrateCommandsToShellCommands(plugin); - save ||= EnsureShellCommandsHaveAllFields(plugin); save ||= MigrateShellCommandToPlatforms(plugin); + save ||= EnsureShellCommandsHaveAllFields(plugin); if (save) { // Only save if there were changes to configuration. console.log("Saving migrations...") @@ -84,17 +84,17 @@ function MigrateShellCommandToPlatforms(plugin: ShellCommandsPlugin) { let save = false; for (let shell_command_id in plugin.settings.shell_commands) { let shell_command_configuration: ShellCommandConfiguration = plugin.settings.shell_commands[shell_command_id]; - if (null !== shell_command_configuration.shell_command) { + if (undefined !== shell_command_configuration.shell_command) { // The shell command should be migrated. - if (undefined !== shell_command_configuration.platforms) { - console.log("Migration failure for shell command #" + shell_command_id + ": shell_commands exists already."); - } else { - console.log("Migrating shell command #" + shell_command_id + ": shell_command string will be moved to shell_commands.default: " + shell_command_configuration.shell_command); + if (undefined === shell_command_configuration.platforms || shell_command_configuration.platforms.default === "") { + console.log("Migrating shell command #" + shell_command_id + ": shell_command string will be moved to platforms.default: " + shell_command_configuration.shell_command); shell_command_configuration.platforms = { default: shell_command_configuration.shell_command, }; - shell_command_configuration.shell_command = null; + delete shell_command_configuration.shell_command; save = true; + } else { + console.log("Migration failure for shell command #" + shell_command_id + ": platforms exists already."); } } } diff --git a/src/settings/ShellCommandConfiguration.ts b/src/settings/ShellCommandConfiguration.ts index 37929ecf..db39e2b4 100644 --- a/src/settings/ShellCommandConfiguration.ts +++ b/src/settings/ShellCommandConfiguration.ts @@ -24,7 +24,7 @@ export interface ShellCommandConfiguration { // LEGACY /** @deprecated Can only be used for migration. */ - shell_command: string; + shell_command?: string; } export function newShellCommandConfiguration(shell_command: string = ""): ShellCommandConfiguration { @@ -41,8 +41,5 @@ export function newShellCommandConfiguration(shell_command: string = ""): ShellC stderr: "notification", }, output_channel_order: "stdout-first", - - // LEGACY - shell_command: null, } } \ No newline at end of file