Skip to content

Commit

Permalink
Fix source and destination dir formatting (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryand56 authored Nov 27, 2022
1 parent 0813090 commit 4a16c65
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ const getFileList = (dir: string) => {
};

const run = async (config: R2Config) => {
// Remove slashes in source dir
config.sourceDir = config.sourceDir.replace(/\\/g, "").replace(/\//g, "");

const map = new Map<string, PutObjectCommandOutput>();
const urls: FileMap = {};

Expand All @@ -59,9 +62,9 @@ const run = async (config: R2Config) => {
console.log(file);
const fileStream = fs.readFileSync(file);
console.log(config.sourceDir);
const sourceDirRegex = new RegExp(config.sourceDir, 'g');
const sourceDirRegex = new RegExp(config.sourceDir + "\\\\", 'g');
console.log(config.destinationDir);
const fileName = file.replace(sourceDirRegex, config.destinationDir);
const fileName = file.replace(sourceDirRegex, path.join(config.destinationDir));

if (fileName.includes('.gitkeep'))
continue;
Expand Down

0 comments on commit 4a16c65

Please sign in to comment.