Skip to content

Commit

Permalink
Carry permissions over when excluding files, fixes #24 (#23)
Browse files Browse the repository at this point in the history
When excluding files from compiled zips in the plugin, permissions were
lost. JSZip was not detecting or setting them from the old archive but this
patch now correctly does it inside applyZipExclude.
  • Loading branch information
arichiardi authored and moea committed Sep 15, 2017
1 parent 29cc3aa commit 135fae0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ const applyZipExclude = bluebird.coroutine(

oldZip
.filter((path, file) => !_.some(exclude, pattern => minimatch(path, pattern)))
.forEach(entry => newZip.file(entry.name, entry.nodeStream("nodebuffer")));
.forEach(entry => newZip.file(entry.name,
entry.nodeStream("nodebuffer"),
_.pick(entry, ["unixPermissions", "dosPermissions", "comment", "date"])));

const buffer = yield newZip.generateAsync({
type: "nodebuffer",
Expand Down
5 changes: 4 additions & 1 deletion serverless-cljs-plugin/serverless_lumo/build.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
[lumo.io :as io]
[serverless-lumo.index :as index]))

(def ^:const zip-comment "Generated by serverless-cljs-plugin on ")

(defn zip!
"Create the zip in output-dir. Return a promise containing the path.
Expand All @@ -22,7 +24,8 @@
- https://archiverjs.com/docs/Archiver.html#file"
[output-path zip-opts compiler-opts]

(let [archiver (archiver "zip" #js {:zlib {:level 9}})
(let [archiver (archiver "zip" #js {:zlib {:level 9}
:comment (str zip-comment (.toISOString (js/Date.)))})
output-stream (.createWriteStream fs output-path)]
(js/Promise.
(fn [resolve-fn reject-fn]
Expand Down

0 comments on commit 135fae0

Please sign in to comment.