@@ -128,12 +128,25 @@ Lambda.prototype._zip = function(program, codeDirectory, callback) {
128
128
zip . file ( file , content ) ;
129
129
}
130
130
} ) ;
131
-
131
+
132
132
var data = zip . generate ( options ) ;
133
133
134
134
return callback ( null , data ) ;
135
135
} ;
136
136
137
+ Lambda . prototype . _nativeZip = function ( program , codeDirectory , callback ) {
138
+ var zipfile = this . _zipfileTmpPath ( program )
139
+ , cmd = 'zip -r ' + zipfile + ' .'
140
+ , run = exec ( cmd , { cwd : codeDirectory } , function ( err , stdout , stderr ) {
141
+ if ( err !== null ) {
142
+ return callback ( err , null )
143
+ }
144
+
145
+ var data = fs . readFileSync ( zipfile )
146
+ callback ( null , data )
147
+ } )
148
+ } ;
149
+
137
150
Lambda . prototype . _codeDirectory = function ( program ) {
138
151
var epoch_time = + new Date ;
139
152
return os . tmpDir ( ) + '/' + program . functionName + '-' + epoch_time ;
@@ -149,7 +162,11 @@ Lambda.prototype.deploy = function(program) {
149
162
// Move all files to tmp folder (except .git, .log, event.json and node_modules)
150
163
_this . _rsync ( program , codeDirectory , function ( err , result ) {
151
164
_this . _npmInstall ( program , codeDirectory , function ( err , result ) {
152
- _this . _zip ( program , codeDirectory , function ( err , buffer ) {
165
+ // Use zip from the command line on non-windows systems to preserve file permissions
166
+ var archive = process . platform != 'win32' ? _this . _nativeZip : _this . _zip ;
167
+ archive = archive . bind ( _this )
168
+
169
+ archive ( program , codeDirectory , function ( err , buffer ) {
153
170
154
171
console . log ( 'Reading zip file to memory' ) ;
155
172
//var buffer = fs.readFileSync(zipfile);
0 commit comments