@@ -30,25 +30,25 @@ define(function (require, exports, module) {
30
30
var basename = Path . basename ( filename ) ;
31
31
32
32
// Skip OS X additions we don't care about in the browser fs
33
- if ( / ^ _ _ M A C O S X \/ / . test ( filename ) ) {
33
+ if ( / ^ _ _ M A C O S X \/ / . test ( filename ) ) {
34
34
// http://superuser.com/questions/104500/what-is-macosx-folder
35
35
return true ;
36
36
}
37
- if ( basename === ".DS_Store" ) {
37
+ if ( basename === ".DS_Store" ) {
38
38
// https://en.wikipedia.org/wiki/.DS_Store
39
39
return true ;
40
40
}
41
- if ( / ^ \. _ / . test ( basename ) ) {
41
+ if ( / ^ \. _ / . test ( basename ) ) {
42
42
// http://apple.stackexchange.com/questions/14980/why-are-dot-underscore-files-created-and-how-can-i-avoid-them
43
43
return true ;
44
44
}
45
45
46
46
// Skip Windows additions we don't care about in the browser fs
47
- if ( / ( T t ) h u m b s \. d b / . test ( basename ) ) {
47
+ if ( / ( T t ) h u m b s \. d b / . test ( basename ) ) {
48
48
// https://en.wikipedia.org/wiki/Windows_thumbnail_cache
49
49
return true ;
50
50
}
51
- if ( basename === "desktop.ini" ) {
51
+ if ( basename === "desktop.ini" ) {
52
52
// http://www.computerhope.com/issues/ch001060.htm
53
53
return true ;
54
54
}
@@ -107,22 +107,22 @@ define(function (require, exports, module) {
107
107
}
108
108
// zipfile can be a path (string) to a zipfile, or raw binary data.
109
109
function unzip ( zipfile , options , callback ) {
110
- if ( typeof options === 'function' ) {
110
+ if ( typeof options === 'function' ) {
111
111
callback = options ;
112
112
options = { } ;
113
113
}
114
114
options = options || { } ;
115
- callback = callback || function ( ) { } ;
115
+ callback = callback || function ( ) { } ;
116
116
117
- if ( ! zipfile ) {
117
+ if ( ! zipfile ) {
118
118
callback ( new Error ( "missing zipfile argument" ) ) ;
119
119
return ;
120
120
}
121
121
122
122
var root = StartupState . project ( "root" ) ;
123
123
var destination = Path . resolve ( options . destination || root ) ;
124
124
125
- function _unzip ( data ) {
125
+ function _unzip ( data ) {
126
126
// TODO: it would be great to move this bit to a worker.
127
127
var archive = new JSZip ( data ) ;
128
128
var filenames = [ ] ;
@@ -143,7 +143,7 @@ define(function (require, exports, module) {
143
143
function decompress ( path , callback ) {
144
144
var basedir = Path . dirname ( path . absPath ) ;
145
145
146
- if ( path . isDirectory ) {
146
+ if ( path . isDirectory ) {
147
147
fs . mkdirp ( path . absPath , callback ) ;
148
148
} else {
149
149
// XXX: some zip files don't seem to be structured such that dirs
@@ -157,7 +157,6 @@ define(function (require, exports, module) {
157
157
return callback ( err ) ;
158
158
}
159
159
if ( stats . type === "FILE" ) {
160
- //console.log("File exists!", path.absPath);
161
160
showOverwriteWarning ( path . absPath , function ( err , result ) {
162
161
if ( err ) {
163
162
return callback ( err ) ;
@@ -186,9 +185,9 @@ define(function (require, exports, module) {
186
185
} ) ;
187
186
}
188
187
189
- if ( typeof zipfile === "string" ) {
188
+ if ( typeof zipfile === "string" ) {
190
189
fs . readFile ( Path . resolve ( root , zipfile ) , function ( err , data ) {
191
- if ( err ) {
190
+ if ( err ) {
192
191
return callback ( err ) ;
193
192
}
194
193
@@ -229,12 +228,12 @@ define(function (require, exports, module) {
229
228
}
230
229
231
230
function addDir ( path , callback ) {
232
- fs . readdir ( path , function ( err , list ) {
231
+ fs . readdir ( path , function ( err , list ) {
233
232
// Add the directory itself
234
233
jszip . folder ( toRelProjectPath ( path ) ) ;
235
234
236
235
// Add all children of this dir, too
237
- async . eachSeries ( list , function ( entry , callback ) {
236
+ async . eachSeries ( list , function ( entry , callback ) {
238
237
add ( Path . join ( path , entry ) , callback ) ;
239
238
} , callback ) ;
240
239
} ) ;
@@ -244,11 +243,11 @@ define(function (require, exports, module) {
244
243
path = Path . resolve ( root , path ) ;
245
244
246
245
fs . stat ( path , function ( err , stats ) {
247
- if ( err ) {
246
+ if ( err ) {
248
247
return callback ( err ) ;
249
248
}
250
249
251
- if ( stats . type === "DIRECTORY" ) {
250
+ if ( stats . type === "DIRECTORY" ) {
252
251
addDir ( path , callback ) ;
253
252
} else {
254
253
addFile ( path , callback ) ;
@@ -257,7 +256,7 @@ define(function (require, exports, module) {
257
256
}
258
257
259
258
add ( root , function ( err ) {
260
- if ( err ) {
259
+ if ( err ) {
261
260
return callback ( err ) ;
262
261
}
263
262
@@ -281,35 +280,37 @@ define(function (require, exports, module) {
281
280
path = Path . resolve ( root , path ) ;
282
281
var basedir = Path . dirname ( path ) ;
283
282
284
- if ( _skipFile ( path ) ) {
283
+ if ( _skipFile ( path ) ) {
285
284
return callback ( ) ;
286
285
}
287
286
288
- fs . mkdirp ( basedir , function ( err ) {
289
- if ( err ) {
287
+ fs . mkdirp ( basedir , function ( err ) {
288
+ if ( err ) {
290
289
return callback ( err ) ;
291
290
}
292
291
293
292
fs . stat ( path , function ( err , stats ) {
294
293
if ( err && err . code !== "ENOENT" ) {
295
294
return callback ( err ) ;
296
295
}
297
- if ( stats . type === "FILE" ) {
298
- showOverwriteWarning ( path , function ( err , result ) {
299
- if ( err ) {
300
- return callback ( err ) ;
301
- }
302
- if ( result === OVERWRITE_OPERATION ) {
303
- fs . writeFile ( path , new Buffer ( data ) , {
304
- encoding : null
305
- } , callback ) ;
306
- } else if ( result === KEEP_EXISITING_OPERATION ) {
307
- callback ( ) ;
308
- } else if ( result === CANCEL_OPERATION ) {
309
- callback ( new Error ( "Operation Cancelled" ) ) ;
310
- }
311
- } ) ;
296
+ if ( stats . type !== "FILE" ) {
297
+ return callback ( ) ;
312
298
}
299
+
300
+ showOverwriteWarning ( path , function ( err , result ) {
301
+ if ( err ) {
302
+ return callback ( err ) ;
303
+ }
304
+ if ( result === OVERWRITE_OPERATION ) {
305
+ fs . writeFile ( path , new Buffer ( data ) , {
306
+ encoding : null
307
+ } , callback ) ;
308
+ } else if ( result === KEEP_EXISITING_OPERATION ) {
309
+ callback ( ) ;
310
+ } else if ( result === CANCEL_OPERATION ) {
311
+ callback ( new Error ( "Operation Cancelled" ) ) ;
312
+ }
313
+ } ) ;
313
314
} ) ;
314
315
} ) ;
315
316
}
@@ -330,20 +331,20 @@ define(function (require, exports, module) {
330
331
}
331
332
332
333
pending -- ;
333
- if ( pending === 0 ) {
334
+ if ( pending === 0 ) {
334
335
_refreshFilesystem ( finish ) ;
335
336
}
336
337
}
337
338
338
339
untarWorker . addEventListener ( "message" , function ( e ) {
339
340
var data = e . data ;
340
341
341
- if ( data . type === "progress" && pending === null ) {
342
+ if ( data . type === "progress" && pending === null ) {
342
343
// Set the total number of files we need to deal with so we know when we're done
343
344
pending = data . totalFilesInArchive ;
344
- } else if ( data . type === "extract" ) {
345
+ } else if ( data . type === "extract" ) {
345
346
extract ( data . unarchivedFile . filename , data . unarchivedFile . fileData , writeCallback ) ;
346
- } else if ( data . type === "error" ) {
347
+ } else if ( data . type === "error" ) {
347
348
finish ( new Error ( "[Bramble untar]: " + data . msg ) ) ;
348
349
}
349
350
} ) ;
0 commit comments