From 135fae0c554296fffab9fb612919b88d8016f6f9 Mon Sep 17 00:00:00 2001 From: Andrea Richiardi Date: Fri, 15 Sep 2017 12:44:25 -0700 Subject: [PATCH] Carry permissions over when excluding files, fixes #24 (#23) 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. --- index.js | 4 +++- serverless-cljs-plugin/serverless_lumo/build.cljs | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 0aa531b..084adec 100644 --- a/index.js +++ b/index.js @@ -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", diff --git a/serverless-cljs-plugin/serverless_lumo/build.cljs b/serverless-cljs-plugin/serverless_lumo/build.cljs index 5cb6b94..16cdebd 100644 --- a/serverless-cljs-plugin/serverless_lumo/build.cljs +++ b/serverless-cljs-plugin/serverless_lumo/build.cljs @@ -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. @@ -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]