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 be 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 the 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.Write a password to the system keychain. Can be used to store other sensitive information such as JWT tokens.
true if the password is written successfully, false otherwise.
The service name. It will be prefixed by the plugin's identifier.
The username.
The password to write.
Open a URL in the system. It can be a http or https link, or a file path.
When it is a web URL, the default browser will be used to open the link.
When it is a file path, magic variables like @data will be resolved, and the file will be revealed in Finder.
true if the URL is opened successfully, false otherwise.
The URL to open.
Generated using TypeDoc
The
Utilsinterface provides utility methods for various operations such as file manipulation, executing external programs, and interacting with the system.Available In Entry
Main and Global entry