Skip to content
This repository has been archived by the owner on Dec 31, 2024. It is now read-only.

Commit

Permalink
Merge pull request oliverschwendener#407 from AmrBinBashir/fix-comman…
Browse files Browse the repository at this point in the history
…dline-plugin-execution-pending

fix commandline plugin execution pending
  • Loading branch information
oliverschwendener authored May 26, 2020
2 parents 7a74a89 + 7df9ee6 commit 414382d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/main/plugins/commandline-plugin/commandline-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,25 @@ import { TranslationSet } from "../../../common/translation/translation-set";
import { defaultTerminalIcon } from "../../../common/icon/default-icons";
import { CommandlineOptions } from "../../../common/config/commandline-options";
import { WindowsShell, MacOsShell } from "./shells";
import { Logger } from "../../../common/logger/logger";

export class CommandlinePlugin implements ExecutionPlugin {
public pluginType = PluginType.Commandline;
private readonly commandlineExecutor: (command: string, shell: WindowsShell|MacOsShell) => Promise<void>;
private config: CommandlineOptions;
private translationSet: TranslationSet;
private readonly logger: Logger;

constructor(
config: CommandlineOptions,
translationSet: TranslationSet,
commandlineExecutor: (command: string, shell: WindowsShell|MacOsShell) => Promise<void>,
logger: Logger,
) {
this.config = config;
this.translationSet = translationSet;
this.commandlineExecutor = commandlineExecutor;
this.logger = logger;
}

public isValidUserInput(userInput: string, fallback?: boolean | undefined): boolean {
Expand Down Expand Up @@ -49,7 +53,10 @@ export class CommandlinePlugin implements ExecutionPlugin {
}

public execute(searchResultItem: SearchResultItem, privileged: boolean): Promise<void> {
return this.commandlineExecutor(searchResultItem.executionArgument, this.config.shell);
this.commandlineExecutor(searchResultItem.executionArgument, this.config.shell)
.then(() => {/* do nothing */ })
.catch(error => this.logger.error(error));
return Promise.resolve();
}

public updateConfig(updatedConfig: UserConfigOptions, translationSet: TranslationSet): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion src/main/production/production-search-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export function getProductionSearchEngine(config: UserConfigOptions, translation
new UrlPlugin(config.urlOptions, translationSet, urlExecutor),
new EmailPlugin(config.emailOptions, translationSet, urlExecutor),
new CurrencyConverterPlugin(config.currencyConverterOptions, translationSet, electronClipboardCopier),
new CommandlinePlugin(config.commandlineOptions, translationSet, commandlineExecutor),
new CommandlinePlugin(config.commandlineOptions, translationSet, commandlineExecutor, logger),
new ColorConverterPlugin(config.colorConverterOptions, electronClipboardCopier),
new DictionaryPlugin(config.dictionaryOptions, electronClipboardCopier, getGoogleDictionaryDefinitions),
];
Expand Down

0 comments on commit 414382d

Please sign in to comment.