Skip to content

Commit

Permalink
#76: Migrations: Fix MigrateShellCommandToPlatforms().
Browse files Browse the repository at this point in the history
  • Loading branch information
Taitava committed Oct 22, 2021
1 parent f0369cd commit 2e0d55b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
14 changes: 7 additions & 7 deletions src/Migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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...")
Expand Down Expand Up @@ -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.");
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/settings/ShellCommandConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -41,8 +41,5 @@ export function newShellCommandConfiguration(shell_command: string = ""): ShellC
stderr: "notification",
},
output_channel_order: "stdout-first",

// LEGACY
shell_command: null,
}
}

0 comments on commit 2e0d55b

Please sign in to comment.