Skip to content

Commit

Permalink
Revert "chore(fmt): format files using prettier"
Browse files Browse the repository at this point in the history
This reverts commit 6d655b3.
  • Loading branch information
ayushmanchhabra committed May 18, 2022
1 parent 6d655b3 commit e49c3ed
Show file tree
Hide file tree
Showing 8 changed files with 1,433 additions and 1,809 deletions.
113 changes: 46 additions & 67 deletions lib/Version.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var platforms = require("./platforms");
var _ = require("lodash");
var semver = require("semver");
var platforms = require('./platforms');
var _ = require('lodash');
var semver = require('semver');

/**
* Represents a version.
Expand All @@ -10,72 +10,51 @@ var semver = require("semver");
* @param {array} args.supportedPlatforms - array of strings like `osx64`.
* @param {string} args.downloadUrl.
*/
module.exports = function Version(args) {
var generatePlatformUrls,
result = {
isLegacy: semver.lt(args.version, "0.12.3"),
name:
semver.gte(args.version, "0.12.0") ||
semver.satisfies(args.version, "~0.12.0-alpha")
? "nwjs"
: "node-webkit",
version: args.version,
};
module.exports = function Version(args){
var generatePlatformUrls,
result = {
isLegacy: semver.lt(args.version, '0.12.3'),
name: semver.gte(args.version, '0.12.0') || semver.satisfies(args.version, '~0.12.0-alpha') ? 'nwjs' : 'node-webkit',
version: args.version
};

// 0.12.3 is an exception that is in the manifest but is pretty much a legacy version
if (result.isLegacy || args.version === "0.12.3") {
generatePlatformUrls = function (version, flavors, supportedPlatforms) {
var platformUrls = {};
supportedPlatforms.forEach(function (supportedPlatform) {
flavors.forEach(function (flavor) {
platformUrls[supportedPlatform + "-" + flavor] =
args.downloadUrl +
_.template(platforms[supportedPlatform].versionNameTemplate)(
result,
);
});
});
return platformUrls;
};
} else {
var fixPlatformName = function (platform) {
return platform.replace("32", "-ia32").replace("64", "-x64");
};
// 0.12.3 is an exception that is in the manifest but is pretty much a legacy version
if(result.isLegacy || args.version === '0.12.3'){
generatePlatformUrls = function(version,flavors, supportedPlatforms){
var platformUrls = {};
supportedPlatforms.forEach(function (supportedPlatform) {
flavors.forEach(function(flavor) {
platformUrls[supportedPlatform + '-' + flavor] = args.downloadUrl + _.template(platforms[supportedPlatform].versionNameTemplate)(result);
});
});
return platformUrls;
};
}
else {
var fixPlatformName = function(platform){
return platform.replace('32', '-ia32').replace('64', '-x64');
};

var mapPlatformToExtension = function (platform) {
if (platform.indexOf("linux") === 0) {
return "tar.gz";
}
var mapPlatformToExtension = function(platform){
if(platform.indexOf('linux') === 0){
return 'tar.gz'
}

return "zip";
};
return 'zip'
};

generatePlatformUrls = function (version, flavors, supportedPlatforms) {
var platformUrls = {};
supportedPlatforms.forEach(function (platform) {
flavors.forEach(function (flavor) {
platformUrls[platform + "-" + flavor] =
args.downloadUrl +
"v" +
version +
"/nwjs" +
(flavor === "normal" ? "" : "-" + flavor) +
"-v" +
version +
"-" +
fixPlatformName(platform) +
"." +
mapPlatformToExtension(platform);
});
});
return platformUrls;
};
}
generatePlatformUrls = function(version, flavors, supportedPlatforms){
var platformUrls = {};
supportedPlatforms.forEach(function(platform){
flavors.forEach(function(flavor) {
platformUrls[platform + '-' + flavor] = args.downloadUrl + 'v' + version + '/nwjs' + (flavor === 'normal' ? '' : '-' + flavor) + '-v' + version + '-' + fixPlatformName(platform)
+ '.' + mapPlatformToExtension(platform);
});
});
return platformUrls;
};
}

result.platforms = generatePlatformUrls(
args.version,
args.flavors,
args.supportedPlatforms,
);
return result;
};
result.platforms = generatePlatformUrls(args.version, args.flavors, args.supportedPlatforms);
return result;
};
19 changes: 8 additions & 11 deletions lib/detectCurrentPlatform.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@
return undefined if platform is unrecognized
*/
module.exports = function () {
switch (process.platform) {
case "darwin":
return process.arch === "x64" ? "osx64" : "osx32";
switch(process.platform) {
case 'darwin':
return process.arch === 'x64' ? 'osx64' : 'osx32';

case "win32":
return process.arch === "x64" ||
process.env.hasOwnProperty("PROCESSOR_ARCHITEW6432")
? "win64"
: "win32";
case 'win32':
return (process.arch === 'x64' || process.env.hasOwnProperty('PROCESSOR_ARCHITEW6432')) ? 'win64' : 'win32';

case "linux":
return process.arch === "x64" ? "linux64" : "linux32";
}
case 'linux':
return process.arch === 'x64' ? 'linux64' : 'linux32';
}
};
Loading

0 comments on commit e49c3ed

Please sign in to comment.