actions_toolkit_sys/
io.rs

1use js_sys::{JsString, Promise};
2use wasm_bindgen::prelude::*;
3
4/// Interface for cp options.
5#[wasm_bindgen]
6#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
7pub struct CopyOptions {
8    /// Whether to recursively copy all subdirectories. Defaults to false.
9    pub recursive: Option<bool>,
10    /// Whether to overwrite existing files in the destination. Defaults to true.
11    pub force: Option<bool>,
12}
13
14/// Interface for mv options.
15#[wasm_bindgen]
16#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
17pub struct MoveOptions {
18    /// Whether to overwrite existing files in the destination. Defaults to true.
19    pub force: Option<bool>,
20}
21
22#[wasm_bindgen(module = "@actions/io")]
23extern {
24    /// Copies a file or folder.
25    #[wasm_bindgen]
26    #[must_use]
27    pub fn cp(source: &JsString, target: &JsString, options: Option<CopyOptions>) -> Promise;
28
29    /// Moves a path.
30    #[wasm_bindgen]
31    #[must_use]
32    pub fn mv(source: &JsString, target: &JsString, options: Option<MoveOptions>) -> Promise;
33
34    /// Remove a path recursively with force.
35    #[wasm_bindgen(js_name = "rmRF")]
36    #[must_use]
37    pub fn rm_rf(path: &JsString) -> Promise;
38
39    /// Make a directory.  Creates the full path with folders in between. Will throw if it fails.
40    #[wasm_bindgen(js_name = "mkdirP")]
41    #[must_use]
42    pub fn mkdir_p(path: &JsString) -> Promise;
43
44    /// Returns path of a tool had the tool actually been invoked.  Resolves via paths. If you check
45    /// and the tool does not exist, it will throw.
46    #[wasm_bindgen]
47    #[must_use]
48    pub fn which(tool: &JsString, check: Option<bool>) -> Promise;
49}