Skip to content

Commit

Permalink
fix: do not run wrangler command in directories
Browse files Browse the repository at this point in the history
Signed-off-by: Diogenes Fernandes <[email protected]>
  • Loading branch information
diofeher committed Feb 25, 2025
1 parent e9c38e6 commit 2b61c91
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions search/worker/scripts/feed-data-r2.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,23 @@ fs.readdir(directoryPath, { recursive: true }, (err, files) => {
const realFilePath = path.join(directoryPath, fileName);
const r2Name = realFilePath.replace(directoryPath, "");

const cmd = `npx wrangler r2 object put registry-ui-api${r2Name} --file ${realFilePath} --local`
console.log(cmd)
exec(cmd, function (err, stdout, stderr) {
console.log(stdout);
console.error(stderr);
});
fs.lstat(realFilePath, (err, stats) => {

if(err)
return console.log(err); //Handle error
if(stats.isDirectory()) {
return console.log(`directories are not supported by wrangler api: ${realFilePath}`)
}

runCmd(r2Name, realFilePath)
});
});
});

const runCmd = (bucketFileName, path) => {
const cmd = `npx wrangler r2 object put registry-ui-api${bucketFileName} --file ${path} --local`
exec(cmd, function (err, stdout, stderr) {
console.log(stdout);
console.error(stderr);
});
}

0 comments on commit 2b61c91

Please sign in to comment.