This commit is contained in:
Trym Lund Flogard 2021-06-02 17:04:43 +02:00
parent 75e2916679
commit e8b44e8c3b
2 changed files with 435 additions and 430 deletions

852
dist/index.js vendored

File diff suppressed because it is too large Load Diff

View File

@ -25,7 +25,7 @@ export class NextcloudClient {
private artifact: string, private artifact: string,
private rootDirectory: string) { private rootDirectory: string) {
this.guid = uuidv4(); this.guid = uuidv4();
this.headers = {'Authorization': 'Basic ' + btoa(`${Inputs.Username}:${Inputs.Password}`)}; this.headers = { 'Authorization': 'Basic ' + btoa(`${Inputs.Username}:${Inputs.Password}`) };
} }
public async uploadFiles(files: string[]) { public async uploadFiles(files: string[]) {
@ -109,9 +109,12 @@ export class NextcloudClient {
const copies = []; const copies = [];
for (let spec of specs) { for (let spec of specs) {
const dstpath = path.join(artifactPath, spec.uploadPath); const dstpath = path.join(artifactPath, spec.uploadPath);
const promise = fs.mkdir(path.dirname(dstpath)) const dstDir = path.dirname(dstpath);
.then(() => fs.copyFile(spec.absolutePath, dstpath)) if (!fsSync.existsSync(dstDir)) {
copies.push(promise); await fs.mkdir(dstDir, { recursive: true });
}
copies.push(fs.copyFile(spec.absolutePath, dstpath));
} }
await Promise.all(copies); await Promise.all(copies);