Because the contents of ${dir} are not escaped when constructing regexp, any regex special characters present in the directory name passed in command line args will cause the filePath.replace(...) expression used to construct the key arg for uploadToS3 to behave unexpectedly.
Given README.md in the current directory and the following invocation:
s3-spa-upload . example-bucket --prefix dest/
The result will be example-bucket/dest/EADME.md.
Although escaping the dir variable when constructing regexp would work, it's probably better to use the path module to deconstruct the filePath and construct the key.
Because the contents of
${dir}
are not escaped when constructingregexp
, any regex special characters present in the directory name passed in command line args will cause thefilePath.replace(...)
expression used to construct thekey
arg foruploadToS3
to behave unexpectedly.Given
README.md
in the current directory and the following invocation:The result will be
example-bucket/dest/EADME.md
.Although escaping the
dir
variable when constructingregexp
would work, it's probably better to use the path module to deconstruct thefilePath
and construct thekey
.