Merge branch 'master' into auth

This commit is contained in:
Danny McCormick 2019-08-05 21:33:24 -04:00 committed by GitHub
commit 6b65ca8e49
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
55 changed files with 240 additions and 3153 deletions

View file

@ -4,4 +4,79 @@
## Usage
See [src/tool-cache.ts](src/tool-cache.ts).
#### Download
You can use this to download tools (or other files) from a download URL:
```
const tc = require('@actions/tool-cache');
const node12Path = await tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz');
```
#### Extract
These can then be extracted in platform specific ways:
```
const tc = require('@actions/tool-cache');
if (process.platform === 'win32') {
tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-win-x64.zip');
const node12ExtractedFolder = await tc.extractZip(node12Path, 'path/to/extract/to');
// Or alternately
tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-win-x64.7z');
const node12ExtractedFolder = await tc.extract7z(node12Path, 'path/to/extract/to');
}
else {
const node12Path = await tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz');
const node12ExtractedFolder = await tc.extractTar(node12Path, 'path/to/extract/to');
}
```
#### Cache
Finally, you can cache these directories in our tool-cache. This is useful if you want to switch back and forth between versions of a tool, or save a tool between runs for private runners (private runners are still in development but are on the roadmap).
You'll often want to add it to the path as part of this step:
```
const tc = require('@actions/tool-cache');
const core = require('@actions/core');
const node12Path = await tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz');
const node12ExtractedFolder = await tc.extractTar(node12Path, 'path/to/extract/to');
const cachedPath = await tc.cacheDir(node12ExtractedFolder, 'node', '12.7.0');
core.addPath(cachedPath);
```
You can also cache files for reuse.
```
const tc = require('@actions/tool-cache');
tc.cacheFile('path/to/exe', 'destFileName.exe', 'myExeName', '1.1.0');
```
#### Find
Finally, you can find directories and files you've previously cached:
```
const tc = require('@actions/tool-cache');
const core = require('@actions/core');
const nodeDirectory = tc.find('node', '12.x', 'x64');
core.addPath(nodeDirectory);
```
You can even find all cached versions of a tool:
```
const tc = require('@actions/tool-cache');
const allNodeVersions = tc.findAllVersions('node');
console.log(`Versions of node available: ${allNodeVersions}`);
```

View file

@ -15,7 +15,6 @@ const os = require("os");
const path = require("path");
const httpm = require("typed-rest-client/HttpClient");
const semver = require("semver");
const shell = require("shelljs");
const uuidV4 = require("uuid/v4");
const exec_1 = require("@actions/exec/lib/exec");
const assert_1 = require("assert");
@ -273,7 +272,7 @@ function cacheDir(sourceDir, tool, version, arch) {
// due to anti-virus software having an open handle on a file.
for (const itemName of fs.readdirSync(sourceDir)) {
const s = path.join(sourceDir, itemName);
shell.cp('-R', s, destPath);
yield io.cp(s, destPath, { recursive: true });
}
// write .complete
_completeToolPath(tool, version, arch);

File diff suppressed because one or more lines are too long

View file

@ -2,7 +2,7 @@
"_from": "file:toolkit\\actions-tool-cache-0.0.0.tgz",
"_id": "@actions/tool-cache@0.0.0",
"_inBundle": false,
"_integrity": "sha512-R08MGFekNLkf1ofh5wi8QVgmFyPgkKC+Cp8FRE1n6zOpHbUWv3QGa6eR6z+2ESuGCstOPtbq/tRgZsSusItm9Q==",
"_integrity": "sha512-33oYAVRdp6MWNT7Yca0//SmOsvpE7FpFfNA/LzwjIZdLucHaO6V67dqZ5p81CTBncrZal+O5kE9B8qSk0rhipg==",
"_location": "/@actions/tool-cache",
"_phantomChildren": {},
"_requested": {
@ -17,10 +17,11 @@
"fetchSpec": "C:\\Users\\Administrator\\Documents\\setup-node\\toolkit\\actions-tool-cache-0.0.0.tgz"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "C:\\Users\\Administrator\\Documents\\setup-node\\toolkit\\actions-tool-cache-0.0.0.tgz",
"_shasum": "e4ffe745db46f47e512db20e80f8ad25910e41d1",
"_shasum": "ce9e7d81ebb138911d20b9f74c8aa6120caac9b1",
"_spec": "@actions/tool-cache@file:toolkit/actions-tool-cache-0.0.0.tgz",
"_where": "C:\\Users\\Administrator\\Documents\\setup-node",
"bugs": {
@ -32,7 +33,6 @@
"@actions/exec": "^0.0.0",
"@actions/io": "^0.0.0",
"semver": "^6.1.0",
"shelljs": "^0.3.0",
"typed-rest-client": "^1.4.0",
"uuid": "^3.3.2"
},