Browse Source

uploadcdn: check for existing tag

Renée Kooi 5 years ago
parent
commit
d3e7bc3181
1 changed files with 13 additions and 4 deletions
  1. 13 4
      bin/upload-to-cdn.js

+ 13 - 4
bin/upload-to-cdn.js

@@ -124,10 +124,6 @@ async function main (packageName, version) {
     ? `${packageName}@${version}`
     : path.join(__dirname, '..', 'packages', packageName)
 
-  const files = remote
-    ? await getRemoteDistFiles(packageName, version)
-    : await getLocalDistFiles(packagePath)
-
   // uppy → releases/uppy/
   // @uppy/robodog → releases/uppy/robodog/
   // @uppy/locales → releases/uppy/locales/
@@ -137,6 +133,19 @@ async function main (packageName, version) {
 
   const outputPath = path.posix.join('releases', dirName, `v${version}`)
 
+  const { Contents: existing } = await s3.listObjects({
+    Bucket: AWS_BUCKET,
+    Prefix: `${AWS_DIRECTORY}/${outputPath}/`
+  }).promise()
+  if (existing.length > 0) {
+    console.error(`Release files for ${dirName} v${version} already exist, exiting...`)
+    process.exit(1)
+  }
+
+  const files = remote
+    ? await getRemoteDistFiles(packageName, version)
+    : await getLocalDistFiles(packagePath)
+
   for (const [filename, buffer] of files.entries()) {
     const key = path.posix.join(AWS_DIRECTORY, outputPath, filename)
     console.log(`pushing s3://${AWS_BUCKET}/${key}`)