The error code returned by utils.exec
when the executable file is not found.
The error code returned by utils.exec
when the executable file is found but cannot be executed.
Check if a binary file exists in the system PATH, or a file exists at the given path.
This method can be used before utils.exec
to check if the executable file exists.
// check if ffmpeg exists in PATH
utils.fileInPath("ffmpeg")
// check if a ffmpeg exists in the plugin's data directory
utils.fileInPath("@data/bin/ffmpeg")
The binary name, or the path to the file.
Execute an external program.
A promise that resolves to an object containing the exit status, standard output and standard error output.
Permission "file-system" must present in Info.json to use this method.
// execute ffmpeg
const { status, stdout, stderr } = await utils.exec("ffmpeg", [
"-i", "input.mp4",
"-vf", "scale=1280:720",
"output.mp4",
]);
The binary name (if it's in the system PATH), or the path to the executable file.
It's recommended to use utils.fileInPath
to check if the executable file exists.
The arguments to pass to the executable file.
Optional
cwd: stringThe working directory of the executable file.
Optional
stdoutHook: ((data: string) => void)Set up a hook to receive the streaming standard output of the executable file.
The newly available standard output data.
Optional
stderrHook: ((data: string) => void)Set up a hook to receive the streaming standard error of the executable file.
The newly available standard error data.
Show a system dialog with "OK" and "Cancel" buttons. Can be used to ask for confirmation, or simply show a message to the user.
true
if the user clicks "OK", false
if the user clicks "Cancel".
const yes = utils.ask("Are you sure you want to delete these files?");
utils.ask("This is a message");
The content of the dialog.
Show a system dialog with an input field to prompt the user for a string input.
// download a file to plugin's data folder with user-input filename
const fn = utils.prompt("Please enter the file name");
http.download("https://example.com/test.zip", `@data/downloads/${fn}`);
The title of the dialog.
Show a system file chooser panel.
Full path of the chosen file or directory.
const path = utils.chooseFile("Please select a subtitle file", {
allowedFileTypes: ["ass", "srt"],
});
core.subtitle.loadTrack(path);
The title of the panel.
Optional options.
chooseDir
: choose a directory instead of a file.allowedFileTypes
: specify a list of available file extensions.
Files without these extensions will be disabled in the panel.Generated using TypeDoc
The
Utils
module provides methods to resolve paths, execute external programs and show system dialogs.Available In Entry
Main and Global entry