Skip to content
This repository was archived by the owner on Jan 14, 2022. It is now read-only.

Commit 65298d6

Browse files
authored
Merge branch 'dev' into master
2 parents 086f718 + 07401d4 commit 65298d6

File tree

13 files changed

+412
-609
lines changed

13 files changed

+412
-609
lines changed

lib/download.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ function download (inputUri, outputFilePath, callback) {
1313
var uri = url.parse(inputUri);
1414

1515
if (inputUri.indexOf('http://') !== 0 && inputUri.indexOf('https://') !== 0) {
16-
// this is to detect scenarios like localhost:8080 where localhost is
17-
// treated as protocol even if it's not.
1816
if (inputUri.indexOf(uri.protocol + '//') !== 0) {
1917
inputUri = 'http://' + inputUri;
2018
uri = url.parse(inputUri);
@@ -55,33 +53,28 @@ function download (inputUri, outputFilePath, callback) {
5553
var deferred = Q.defer();
5654
protocol.get(options, function (res) {
5755

58-
// If Moved Permanently or Found, redirect to new URL
5956
if ([301, 302].indexOf(res.statusCode) > -1) {
6057
return download(res.headers.location, outputFilePath)
6158
.then(function (result) { deferred.resolve(result); })
6259
.catch(function (err) { deferred.reject(err); });
6360
}
6461

65-
// If not OK or Not Modified, throw error
6662
if ([200, 304].indexOf(res.statusCode) === -1) {
6763
var err = new Error('Error downloading \'' + inputUri + '\'. Response was \'' + res.statusCode + ' - ' + res.statusMessage + '\'.');
6864
err.statusCode = res.statusCode;
6965
err.statusMessage = res.statusMessage;
7066
return deferred.reject(err);
7167
}
7268

73-
// If Not Modified, ignore
7469
if (res.statusCode === 304) {
7570
return deferred.resolve({ 'path': outputFilePath, 'statusCode': res.statusCode, 'statusMessage': res.statusMessage, 'contentType': res.headers['content-type'] });
7671
}
7772

78-
// Else save
7973
res.pipe(fs.createWriteStream(outputFilePath))
8074
.on('close', function () {
8175
var lastAccessed = new Date();
8276
var lastModified = res.headers['last-modified'] ? new Date(res.headers['last-modified']) : lastAccessed;
8377

84-
// update the last modified time of the file to match the response header
8578
fs.utimes(outputFilePath, lastAccessed, lastModified, function (err) {
8679
if (err) {
8780
return deferred.reject(err);

lib/fileTools.js

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ function copyFolder (source, target, options, callback) {
7777
}
7878

7979
return Q.nfcall(ncp, source, target, options || {}).catch(function (err) {
80-
// flatten errors, otherwise it breaks things downstream
81-
// see https://github.com/AvianFlu/ncp/issues/52
8280
if (Array.isArray(err)) {
8381
var msg = err.reduce(function (previous, current) {
8482
return previous += (previous.length ? '\n' : '') + current.message;
@@ -101,11 +99,9 @@ function replaceFileContent (source, replacementFunc, callback) {
10199
}
102100

103101
function mkdirp (filePath, callback) {
104-
// ensure filePath points to a valid drive
105102
var fullPath = path.resolve(filePath);
106103
var rootPath = path.parse(fullPath).root;
107104

108-
// create directory recursively
109105
return stat(rootPath).then(function () {
110106
return Q.nfcall(_mkdirp, filePath);
111107
})
@@ -210,36 +206,28 @@ function folderScanSync(directory) {
210206
// required directory structure.
211207
function syncFile (source, target, callback) {
212208

213-
// check target file
214209
return stat(target).then(function (info) {
215-
// verify that target is a file and not a directory
216210
if (info.isDirectory()) {
217211
return Q.reject(new Error('Cannot synchronize file \'' + source + '\'. There is already a directory in the target with the same name.'));
218212
}
219213

220-
// skip target if it already exists
221214
return;
222215
})
223216
.catch(function (err) {
224-
// return failure for anything other than 'not found'
225217
if (err.code !== 'ENOENT') {
226218
return Q.reject(err);
227219
}
228220

229-
// copy source to target
230221
var targetDir = path.dirname(target);
231222
return stat(targetDir).catch(function (err) {
232-
// return failure for anything other than 'not found'
233223
if (err.code !== 'ENOENT') {
234224
return Q.reject(err);
235225
}
236226

237-
// create target directory
238227
return mkdirp(targetDir).then(function () {
239228
log.debug('Created target directory at \'' + targetDir + '\'.');
240229
})
241230
.catch(function (err) {
242-
// ignore error if target was already created by a different "thread"
243231
if (err.code !== 'EEXIST') {
244232
return Q.reject(err);
245233
}
@@ -273,37 +261,30 @@ function syncFiles (source, target, options, callback) {
273261
options = {};
274262
}
275263

276-
// read the contents of the source directory
277264
return Q.nfcall(fs.readdir, source).then(function (files) {
278265

279-
// process each file and folder
280266
var tasks = files.map(function (fileOrDir) {
281267
var sourceFile = path.join(source, fileOrDir);
282268
return stat(sourceFile).then(function (info) {
283269

284-
// if fileOrDir is a directory, synchronize it
285270
if (info.isDirectory()) {
286271
return syncFiles(sourceFile, path.join(target, fileOrDir), options);
287272
}
288273

289-
// check to see if file should be skipped
290274
if (options.filter) {
291275
var check = options.filter(fileOrDir);
292276
if (check === false) {
293277
return;
294278
}
295279
}
296280

297-
// synchronize a single file
298281
var targetFile = path.join(target, fileOrDir);
299282
return syncFile(sourceFile, targetFile);
300283
});
301284
});
302285

303-
// wait for all pending tasks to complete
304286
return Q.all(tasks).then(function (values) {
305287

306-
// build a list of the files that were copied
307288
return values.reduce(function (list, value) {
308289
if (value) {
309290
if (Array.isArray(value)) {
@@ -323,17 +304,13 @@ function syncFiles (source, target, options, callback) {
323304
return Q.reject(err);
324305
}
325306

326-
// specified source is a file not a directory
327307
var sourceFile = path.basename(source);
328308
var targetFile = path.basename(target);
329309

330-
// build target file path assuming target is a directory
331-
// unless target already includes the file name
332310
if (sourceFile !== targetFile) {
333311
target = path.join(target, sourceFile);
334312
}
335313

336-
// synchronize the file
337314
return syncFile(source, target).then(function (file) {
338315
return file ? [file] : [];
339316
});

lib/iconTools.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ function getIcon(iconUrl, iconFilePath, callback) {
1717
return fileTools.mkdirp(iconFolder).then(function () {
1818
return download(iconUrl, iconFilePath).then(function (response) {
1919
if (response.statusCode === 200 && !response.contentType.match(/image/)) {
20-
// If not an image, return an error
2120
return Q.reject(new Error('Downloaded file \'' + iconUrl + '\' does not appear to be an image. The content type of the response was \'' + response.contentType + '\'.'));
2221
}
2322

@@ -29,7 +28,6 @@ function getIcon(iconUrl, iconFilePath, callback) {
2928

3029
function copyDefaultIcon(manifest, platformId, iconSize, source, targetPath, callback) {
3130

32-
// platform already contains an icon with this size - skip
3331
if (manifest.icons && manifest.icons[iconSize]) {
3432
return Q.resolve().nodeify(callback);
3533
}

lib/manifestTools/manifestCreator/scrapers/icojs/src/ico.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@ var imageData = require('./image-data');
66
var Q = require('q');
77

88
var range = function(n) {
9-
// fill() replaced with for ..
109
var array = new Array(n);
1110
for (var i = 0; i < n; i++) {
1211
array[i] = 0;
1312
}
1413

1514
return array.map(function(x, i) { return i; });
16-
17-
// return new Array(n).fill(0).map(function(_, i) { return i });
1815
};
1916

2017
/**
@@ -159,8 +156,6 @@ var factory = function(config) {
159156
return false;
160157
}
161158
var icoDv = new DataView(buffer);
162-
// idReserved = icoDv.getUint16(0, true)
163-
// idType = icoDv.getUint16(0, true)
164159
return icoDv.getUint16(0, true) === 0 && icoDv.getUint16(2, true) === 1;
165160
},
166161
/**

lib/manifestTools/manifestLoader.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ function processManifestContents (data, manifestFormat, callback) {
7575
detectedFormat = manifestFormat;
7676
} else if (!detectedFormat) {
7777
detectedFormat = 'w3c';
78-
// var availableFormats = listAvailableManifestFormats().join(', ');
79-
//return callback(new Error('Unable to detect the input manifest format. Try specifying the correct format using the -f <format> option. Available formats are: ' + availableFormats + '.'));
8078
}
8179

8280
log.info('Found a ' + detectedFormat + ' manifest...');

0 commit comments

Comments
 (0)