Skip to content

Commit ce35879

Browse files
committed
Removed white-spaces and removed comments
1 parent 287080b commit ce35879

File tree

1 file changed

+41
-40
lines changed

1 file changed

+41
-40
lines changed

src/filesystem/impls/filer/ArchiveUtils.js

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,25 @@ define(function (require, exports, module) {
3030
var basename = Path.basename(filename);
3131

3232
// Skip OS X additions we don't care about in the browser fs
33-
if (/^__MACOSX\//.test(filename)) {
33+
if(/^__MACOSX\//.test(filename)) {
3434
// http://superuser.com/questions/104500/what-is-macosx-folder
3535
return true;
3636
}
37-
if (basename === ".DS_Store") {
37+
if(basename === ".DS_Store") {
3838
// https://en.wikipedia.org/wiki/.DS_Store
3939
return true;
4040
}
41-
if (/^\._/.test(basename)) {
41+
if(/^\._/.test(basename)) {
4242
// http://apple.stackexchange.com/questions/14980/why-are-dot-underscore-files-created-and-how-can-i-avoid-them
4343
return true;
4444
}
4545

4646
// Skip Windows additions we don't care about in the browser fs
47-
if (/(Tt)humbs\.db/.test(basename)) {
47+
if(/(Tt)humbs\.db/.test(basename)) {
4848
// https://en.wikipedia.org/wiki/Windows_thumbnail_cache
4949
return true;
5050
}
51-
if (basename === "desktop.ini") {
51+
if(basename === "desktop.ini") {
5252
// http://www.computerhope.com/issues/ch001060.htm
5353
return true;
5454
}
@@ -107,22 +107,22 @@ define(function (require, exports, module) {
107107
}
108108
// zipfile can be a path (string) to a zipfile, or raw binary data.
109109
function unzip(zipfile, options, callback) {
110-
if (typeof options === 'function') {
110+
if(typeof options === 'function') {
111111
callback = options;
112112
options = {};
113113
}
114114
options = options || {};
115-
callback = callback || function () {};
115+
callback = callback || function() {};
116116

117-
if (!zipfile) {
117+
if(!zipfile) {
118118
callback(new Error("missing zipfile argument"));
119119
return;
120120
}
121121

122122
var root = StartupState.project("root");
123123
var destination = Path.resolve(options.destination || root);
124124

125-
function _unzip(data) {
125+
function _unzip(data){
126126
// TODO: it would be great to move this bit to a worker.
127127
var archive = new JSZip(data);
128128
var filenames = [];
@@ -143,7 +143,7 @@ define(function (require, exports, module) {
143143
function decompress(path, callback) {
144144
var basedir = Path.dirname(path.absPath);
145145

146-
if (path.isDirectory) {
146+
if(path.isDirectory) {
147147
fs.mkdirp(path.absPath, callback);
148148
} else {
149149
// XXX: some zip files don't seem to be structured such that dirs
@@ -157,7 +157,6 @@ define(function (require, exports, module) {
157157
return callback(err);
158158
}
159159
if (stats.type === "FILE") {
160-
//console.log("File exists!", path.absPath);
161160
showOverwriteWarning(path.absPath, function (err, result) {
162161
if (err) {
163162
return callback(err);
@@ -186,9 +185,9 @@ define(function (require, exports, module) {
186185
});
187186
}
188187

189-
if (typeof zipfile === "string") {
188+
if(typeof zipfile === "string") {
190189
fs.readFile(Path.resolve(root, zipfile), function (err, data) {
191-
if (err) {
190+
if(err) {
192191
return callback(err);
193192
}
194193

@@ -229,12 +228,12 @@ define(function (require, exports, module) {
229228
}
230229

231230
function addDir(path, callback) {
232-
fs.readdir(path, function (err, list) {
231+
fs.readdir(path, function(err, list) {
233232
// Add the directory itself
234233
jszip.folder(toRelProjectPath(path));
235234

236235
// Add all children of this dir, too
237-
async.eachSeries(list, function (entry, callback) {
236+
async.eachSeries(list, function(entry, callback) {
238237
add(Path.join(path, entry), callback);
239238
}, callback);
240239
});
@@ -244,11 +243,11 @@ define(function (require, exports, module) {
244243
path = Path.resolve(root, path);
245244

246245
fs.stat(path, function (err, stats) {
247-
if (err) {
246+
if(err) {
248247
return callback(err);
249248
}
250249

251-
if (stats.type === "DIRECTORY") {
250+
if(stats.type === "DIRECTORY") {
252251
addDir(path, callback);
253252
} else {
254253
addFile(path, callback);
@@ -257,7 +256,7 @@ define(function (require, exports, module) {
257256
}
258257

259258
add(root, function (err) {
260-
if (err) {
259+
if(err) {
261260
return callback(err);
262261
}
263262

@@ -281,35 +280,37 @@ define(function (require, exports, module) {
281280
path = Path.resolve(root, path);
282281
var basedir = Path.dirname(path);
283282

284-
if (_skipFile(path)) {
283+
if(_skipFile(path)) {
285284
return callback();
286285
}
287286

288-
fs.mkdirp(basedir, function (err) {
289-
if (err) {
287+
fs.mkdirp(basedir, function(err) {
288+
if(err) {
290289
return callback(err);
291290
}
292291

293292
fs.stat(path, function (err, stats) {
294293
if (err && err.code !== "ENOENT") {
295294
return callback(err);
296295
}
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();
312298
}
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+
});
313314
});
314315
});
315316
}
@@ -330,20 +331,20 @@ define(function (require, exports, module) {
330331
}
331332

332333
pending--;
333-
if (pending === 0) {
334+
if(pending === 0) {
334335
_refreshFilesystem(finish);
335336
}
336337
}
337338

338339
untarWorker.addEventListener("message", function (e) {
339340
var data = e.data;
340341

341-
if (data.type === "progress" && pending === null) {
342+
if(data.type === "progress" && pending === null) {
342343
// Set the total number of files we need to deal with so we know when we're done
343344
pending = data.totalFilesInArchive;
344-
} else if (data.type === "extract") {
345+
} else if(data.type === "extract") {
345346
extract(data.unarchivedFile.filename, data.unarchivedFile.fileData, writeCallback);
346-
} else if (data.type === "error") {
347+
} else if(data.type === "error") {
347348
finish(new Error("[Bramble untar]: " + data.msg));
348349
}
349350
});

0 commit comments

Comments
 (0)