Skip to content

Commit

Permalink
fix: fileName does not respect directory structure
Browse files Browse the repository at this point in the history
  • Loading branch information
ryand56 committed Jul 31, 2024
1 parent 49d133a commit 5723b85
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ const run = async (config: R2Config) => {
console.log(file);
console.log(config.sourceDir);
console.log(config.destinationDir);
//const fileName = file.replace(/^.*[\\\/]/, "");
const fileName = path.basename(file);
const fileName = file.replace(config.sourceDir, "");
const fileKey = path.join(config.destinationDir !== "" ? config.destinationDir : config.sourceDir, fileName);

if (fileKey.includes('.gitkeep'))
Expand Down
3 changes: 2 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fs from 'fs';
import path from 'path';

export const formatBytes = function (bytes: number): string {
const sizes = ["Bytes", "KB", "MB", "GB", "TB"]
Expand Down Expand Up @@ -30,7 +31,7 @@ export const getFileList = (dir: string) => {

for (const item of items) {
const isDir = item.isDirectory();
const absolutePath = `${dir}/${item.name}`;
const absolutePath = path.join(dir, item.name);
if (isDir) {
files = [...files, ...getFileList(absolutePath)];
} else {
Expand Down

0 comments on commit 5723b85

Please sign in to comment.