Update package docs (#38)

* Update README.md

* Add exec guidance

* Add io guidance

* Add tool-cache guidance

* Readability

* Readability

* Readability

* Nit

* Nit

* Nit
This commit is contained in:
Danny McCormick authored and Bryan MacFarlane committed 2019-08-04 09:00:04 -04:00
1 parent 607332c77e
commit c2e3e1864f
1 file changed
+44 -40
+44 -40
View File
@@ -4,46 +4,50 @@
## Usage ## 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:
``` ```
/** const io = require('@actions/io');
* Copies a file or folder.
*
* @param source source path
* @param dest destination path
* @param options optional. See CopyOptions.
*/
export function cp(source: string, dest: string, options?: CopyOptions): Promise<void>
/** await io.mkdirP('path/to/make');
* Remove a path recursively with force ```
*
* @param path path to remove #### cp/mv
*/
export function rmRF(path: string): Promise<void> 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):
/** ```
* Make a directory. Creates the full path with folders in between const io = require('@actions/io');
*
* @param p path to create // Recursive must be true for directories
* @returns Promise<void> const options = { recursive: true, force: false }
*/
export function mkdirP(p: string): Promise<void> await io.cp('path/to/directory', 'path/to/dest', options);
await io.mv('path/to/file', 'path/to/dest');
/** ```
* Moves a path.
* #### rm -rf
* @param source source path
* @param dest destination path 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.
* @param options optional. See CopyOptions.
*/ ```
export function mv(source: string, dest: string, options?: CopyOptions): Promise<void> const io = require('@actions/io');
/** await io.rmRF('path/to/directory');
* Returns path of a tool had the tool actually been invoked. Resolves via paths. await io.rmRF('path/to/file');
* ```
* @param tool name of the tool
* @param options optional. See WhichOptions. #### which
* @returns Promise<string> path to tool
*/ Get the path to a tool and resolves via paths. Follows the rules specified in [man which](https://linux.die.net/man/1/which).
export function which(tool: string, options?: WhichOptions): Promise<string>
```
const exec = require('@actions/exec');
const io = require('@actions/io');
const pythonPath: string = await io.which('python', true)
await exec.exec(`"${pythonPath}"`, ['main.py']);
``` ```