1
0
Fork 0

PR Feedback

pull/340/head
Konrad Pabjan 2020-02-13 00:29:32 -05:00
parent 79ea6027c6
commit 244f26a941
3 changed files with 9 additions and 13 deletions

View File

@ -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
}

View File

@ -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
})
}

View File

@ -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}`)
}
}
}