summaryrefslogtreecommitdiffstatshomepage
path: root/node_modules/@actions/io/README.md
blob: 9aadf2f95cb142d71998805d8fa1ffca795b791d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# `@actions/io`

> Core functions for cli filesystem scenarios

## Usage

#### mkdir -p

Recursively make a directory. Follows rules specified in [man mkdir](https://linux.die.net/man/1/mkdir) with the `-p` option specified:

```js
const io = require('@actions/io');

await io.mkdirP('path/to/make');
```

#### cp/mv

Copy or move files or folders. Follows rules specified in [man cp](https://linux.die.net/man/1/cp) and [man mv](https://linux.die.net/man/1/mv):

```js
const io = require('@actions/io');

// Recursive must be true for directories
const options = { recursive: true, force: false }

await io.cp('path/to/directory', 'path/to/dest', options);
await io.mv('path/to/file', 'path/to/dest');
```

#### rm -rf

Remove a file or folder recursively. Follows rules specified in [man rm](https://linux.die.net/man/1/rm) with the `-r` and `-f` rules specified.

```js
const io = require('@actions/io');

await io.rmRF('path/to/directory');
await io.rmRF('path/to/file');
```

#### which

Get the path to a tool and resolves via paths. Follows the rules specified in [man which](https://linux.die.net/man/1/which).

```js
const exec = require('@actions/exec');
const io = require('@actions/io');

const pythonPath: string = await io.which('python', true)

await exec.exec(`"${pythonPath}"`, ['main.py']);
```