mirror of https://github.com/actions/toolkit
PR Feedback
parent
79ea6027c6
commit
244f26a941
|
@ -2,7 +2,7 @@
|
|||
|
||||
## Usage
|
||||
|
||||
You can use this package to interact with the actions artifact service to upload and download artifacts.
|
||||
You can use this package to interact with the actions artifacts.
|
||||
- [Upload an Artifact](##Upload-an-Artifact)
|
||||
- [Download a Single Artifact](##Download-a-Single-Artifact)
|
||||
- [Download All Artifacts](##Download-all-Artifacts)
|
||||
|
@ -67,7 +67,7 @@ const files = [
|
|||
'dir/file3.txt'
|
||||
]
|
||||
|
||||
const rootDirectory = '.' // Also possible to specify __dirname if using node
|
||||
const rootDirectory = '.' // Also possible to specify __dirname
|
||||
const options = {
|
||||
continueOnError: false
|
||||
}
|
||||
|
|
|
@ -217,12 +217,13 @@ export class DefaultArtifactClient implements ArtifactClient {
|
|||
await Promise.all(
|
||||
parallelDownloads.map(async () => {
|
||||
while (downloadedArtifacts < artifacts.count) {
|
||||
const currentArtifactToUpload = artifacts.value[downloadedArtifacts]
|
||||
const currentArtifactToDownload =
|
||||
artifacts.value[downloadedArtifacts]
|
||||
downloadedArtifacts += 1
|
||||
|
||||
// Promise.All is not correctly inferring that 'path' is no longer possibly undefined: https://github.com/microsoft/TypeScript/issues/34925
|
||||
const downloadSpecification = getDownloadSpecification(
|
||||
currentArtifactToUpload.name,
|
||||
currentArtifactToDownload.name,
|
||||
items.value,
|
||||
path!, // eslint-disable-line @typescript-eslint/no-non-null-assertion
|
||||
true
|
||||
|
@ -233,7 +234,7 @@ export class DefaultArtifactClient implements ArtifactClient {
|
|||
await downloadSingleArtifact(downloadSpecification.filesToDownload)
|
||||
|
||||
response.push({
|
||||
artifactName: currentArtifactToUpload.name,
|
||||
artifactName: currentArtifactToDownload.name,
|
||||
downloadPath: downloadSpecification.rootDownloadLocation
|
||||
})
|
||||
}
|
||||
|
|
|
@ -53,21 +53,16 @@ export function getDownloadSpecification(
|
|||
includeRootDirectory ? entry.path : entry.path.replace(artifactName, '')
|
||||
)
|
||||
|
||||
// Case insensitive folder structure maintained in the backend, not every folder is created so the 'folder'
|
||||
// itemType cannot be relied upon. The file must be used to determine the directory structure
|
||||
if (entry.itemType === 'file') {
|
||||
// get the directories that we need to create from the filePath for each individual file
|
||||
// Get the directories that we need to create from the filePath for each individual file
|
||||
directories.add(path.dirname(filePath))
|
||||
|
||||
specifications.filesToDownload.push({
|
||||
sourceLocation: entry.contentLocation,
|
||||
targetPath: filePath
|
||||
})
|
||||
} else if (entry.itemType === 'folder') {
|
||||
// case insensitive folder structure maintained in the backend, not every folder is created so the
|
||||
// path for the file must be used to determine the directory structure
|
||||
} else {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(entry)
|
||||
throw new Error(`Unsupported item type: ${entry.itemType}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue