Skip to content

Commit

Permalink
feat(Command): [OpenAndRun] support custom delay time
Browse files Browse the repository at this point in the history
  • Loading branch information
Declan Zou committed Feb 20, 2022
1 parent 4c6ce02 commit 2d561d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
13 changes: 12 additions & 1 deletion src/commands/changeFile/openAndRun.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ export const openAndRunCommand = vscode.commands.registerCommand(

if (commands.length === 0) return;

const betweenMessage =
'Please enter timer (ms) for delay between each command';

const timer = await vscode.window.showInputBox({
title: betweenMessage,
placeHolder: betweenMessage,
value: '0',
});

if (Number.isNaN(+timer!) || timer === null) return;

await vscode.window.withProgress(
{
cancellable: false,
Expand All @@ -46,7 +57,7 @@ export const openAndRunCommand = vscode.commands.registerCommand(
return;
});

await new ChangeFileHandler(dirPath).openAndRun(commands);
await new ChangeFileHandler(dirPath).openAndRun(commands, +timer!);
},
);
} catch (error: any) {
Expand Down
4 changes: 2 additions & 2 deletions src/handlers/changeFile.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export class ChangeFileHandler {
/**
* open that file and run each commands one by one
*/
async openAndRun(commands: string[]) {
async openAndRun(commands: string[], timer = 300) {
for (const fromUrl of this.fileTree) {
await new RunCommandHandler(fromUrl).openAndRun(commands);
await new RunCommandHandler(fromUrl).openAndRun(commands, timer);
}
}

Expand Down

0 comments on commit 2d561d1

Please sign in to comment.