bufferapp / buffer-static-upload

šŸ“ā†’ā˜ļøšŸ¤˜ Making it easy to upload your static assets
MIT License
4 stars 4 forks source link

Allow upload of all files in directory w/out require glob patterns #20

Open djfarrelly opened 5 years ago

djfarrelly commented 5 years ago

Purpose

It can get a bit tedious to write our all of the file glob patterns and with directories that are pretty clean, we don't need this high level of control.

Notes

Currently, lots of our apps are using bash to work around this which lens to complex and verbose code:

FILE_GLOBS=(
  'public/css/*.css'
  'public/js/*.js'
  'public/img/*.*'
  'public/img/**/*.*'
  'public/img/**/**/*.*'
  'public/video/*.*'
  'public/video/**/*.*'
  'public/misc/*.*'
  'public/fonts/*.*'
  'static/**/*.*'
)
# this joins the above array into a comma-delineated string
FILES=$(printf ",%s" "${FILE_GLOBS[@]}") 
FILES=${FILES:1} # slice the first "," char

./buffer-static-upload -files "$FILES" -dir marketing

Idea

We could simplify this as we're uploading everything in static with that glob and most of the other directories which gets a bit verbose. We traverse the entire directory and upload all files, perhaps skipping .DS_Store's. and other files like that.

./buffer-static-upload -files "public,static" -dir marketing

Optional bonus idea We could add an argument like -ext to allow someone to only match certain extensions in a given directory.

./buffer-static-upload -files "public,static" -dir marketing -ext "js,css,mp4,woff"