mirror of
https://code.forgejo.org/forgejo/download-artifact.git
synced 2025-05-16 12:27:47 +02:00
Add support for tilde expansion (#50)
* Add support for tilde expansion * Print resolved path with debug * Update README * README * Only replace tilde in certain scenarios * Fix
This commit is contained in:
parent
83fcc74d04
commit
381af06b42
4 changed files with 49 additions and 11 deletions
16
dist/index.js
vendored
16
dist/index.js
vendored
|
@ -6634,6 +6634,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = __importStar(__webpack_require__(470));
|
||||
const artifact = __importStar(__webpack_require__(214));
|
||||
const os = __importStar(__webpack_require__(87));
|
||||
const path_1 = __webpack_require__(622);
|
||||
const constants_1 = __webpack_require__(694);
|
||||
function run() {
|
||||
|
@ -6641,12 +6642,21 @@ function run() {
|
|||
try {
|
||||
const name = core.getInput(constants_1.Inputs.Name, { required: false });
|
||||
const path = core.getInput(constants_1.Inputs.Path, { required: false });
|
||||
let resolvedPath;
|
||||
// resolve tilde expansions, path.replace only replaces the first occurrence of a pattern
|
||||
if (path.startsWith(`~`)) {
|
||||
resolvedPath = path_1.resolve(path.replace('~', os.homedir()));
|
||||
}
|
||||
else {
|
||||
resolvedPath = path_1.resolve(path);
|
||||
}
|
||||
core.debug(`Resolved path is ${resolvedPath}`);
|
||||
const artifactClient = artifact.create();
|
||||
if (!name) {
|
||||
// download all artifacts
|
||||
core.info('No artifact name specified, downloading all artifacts');
|
||||
core.info('Creating an extra directory for each artifact that is being downloaded');
|
||||
const downloadResponse = yield artifactClient.downloadAllArtifacts(path);
|
||||
const downloadResponse = yield artifactClient.downloadAllArtifacts(resolvedPath);
|
||||
core.info(`There were ${downloadResponse.length} artifacts downloaded`);
|
||||
for (const artifact of downloadResponse) {
|
||||
core.info(`Artifact ${artifact.artifactName} was downloaded to ${artifact.downloadPath}`);
|
||||
|
@ -6658,12 +6668,12 @@ function run() {
|
|||
const downloadOptions = {
|
||||
createArtifactFolder: false
|
||||
};
|
||||
const downloadResponse = yield artifactClient.downloadArtifact(name, path, downloadOptions);
|
||||
const downloadResponse = yield artifactClient.downloadArtifact(name, resolvedPath, downloadOptions);
|
||||
core.info(`Artifact ${downloadResponse.artifactName} was downloaded to ${downloadResponse.downloadPath}`);
|
||||
}
|
||||
// output the directory that the artifact(s) was/were downloaded to
|
||||
// if no path is provided, an empty string resolves to the current working directory
|
||||
core.setOutput(constants_1.Outputs.DownloadPath, path_1.resolve(path));
|
||||
core.setOutput(constants_1.Outputs.DownloadPath, resolvedPath);
|
||||
core.info('Artifact download has finished successfully');
|
||||
}
|
||||
catch (err) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue