File tree Expand file tree Collapse file tree 2 files changed +22
-4
lines changed Expand file tree Collapse file tree 2 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ export async function RunMigrations(plugin: ShellCommandsPlugin) {
55 let save = MigrateCommandsToShellCommands ( plugin ) ;
66 save ||= MigrateShellCommandToPlatforms ( plugin ) ;
77 save ||= EnsureShellCommandsHaveAllFields ( plugin ) ;
8+ save ||= DeleteEmptyCommandsField ( plugin ) ;
89 if ( save ) {
910 // Only save if there were changes to configuration.
1011 console . log ( "Saving migrations..." )
@@ -14,6 +15,9 @@ export async function RunMigrations(plugin: ShellCommandsPlugin) {
1415}
1516
1617function MigrateCommandsToShellCommands ( plugin : ShellCommandsPlugin ) {
18+ if ( undefined === plugin . settings . commands ) {
19+ return false ;
20+ }
1721 let count_shell_commands = plugin . settings . commands . length ;
1822 let save = false ;
1923 if ( 0 < count_shell_commands ) {
@@ -99,4 +103,21 @@ function MigrateShellCommandToPlatforms(plugin: ShellCommandsPlugin) {
99103 }
100104 }
101105 return save ;
106+ }
107+
108+ /**
109+ * Can be removed in 1.0.0.
110+ *
111+ * @param plugin
112+ * @constructor
113+ */
114+ function DeleteEmptyCommandsField ( plugin : ShellCommandsPlugin ) {
115+ let save = false ;
116+ if ( undefined !== plugin . settings . commands ) {
117+ if ( plugin . settings . commands . length === 0 ) {
118+ delete plugin . settings . commands ;
119+ save = true ;
120+ }
121+ }
122+ return save ;
102123}
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ export interface ShellCommandsPluginSettings {
1111
1212 // Legacy:
1313 /** @deprecated Use shell_commands object instead of this array. From now on, this array can be used only for migrating old configuration to shell_commands.*/
14- commands : string [ ] ;
14+ commands ? : string [ ] ;
1515}
1616
1717export const DEFAULT_SETTINGS : ShellCommandsPluginSettings = {
@@ -21,9 +21,6 @@ export const DEFAULT_SETTINGS: ShellCommandsPluginSettings = {
2121 shell_commands : { } ,
2222 error_message_duration : 20 ,
2323 notification_message_duration : 10 ,
24-
25- // Legacy:
26- commands : [ ] // Deprecated, but must be present in the default values as long as migrating from commands to shell_commands is supported.
2724}
2825
2926/**
You can’t perform that action at this time.
0 commit comments