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

Commit 5b41ed6

Browse files
author
Lucas Rojas
committed
Clen comments from platformtools.js
1 parent b55a7ba commit 5b41ed6

File tree

1 file changed

+0
-25
lines changed

1 file changed

+0
-25
lines changed

lib/platformTools.js

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ function getPlatformModule(packageName, source) {
3434
return Q.reject(new CustomError('Failed to resolve module: \'' + packageName + '\'.', err));
3535
}
3636

37-
// queue the installation of the package, it will be installed once installQueuedPackages
38-
// is called, then re-attempt to require the package.
3937
return packageTools.queuePackageInstallation(packageName, source).then(function() {
4038
var module = require(packageName);
4139
return Q.resolve(module);
@@ -51,14 +49,11 @@ function loadPlatform(packageName, source, callback) {
5149
.nodeify(callback);
5250
}
5351

54-
// configures the platforms with the provided configuration or attempts to load
55-
// the configuration from a 'platforms.json' file in the root of the main app
5652
function configurePlatforms(config) {
5753
if (!config) {
5854
config = getDefaultConfigPath();
5955
}
6056

61-
// if config is a file path, load the file
6257
if (config && typeof config === 'string') {
6358
try {
6459
config = require(config);
@@ -71,7 +66,6 @@ function configurePlatforms(config) {
7166
platformConfiguration = config;
7267
}
7368

74-
// returns the modules implementing the requested platforms
7569
function loadPlatforms(platforms, config, callback) {
7670

7771
if (arguments.length < 3) {
@@ -81,25 +75,19 @@ function loadPlatforms(platforms, config, callback) {
8175
}
8276
}
8377

84-
// if configurePlatforms has not been called yet, loads the default configuration
8578
configurePlatforms(config || platformConfiguration);
8679

8780
var platformMap = {};
88-
// load all platform modules and map the corresponding platforms to each one, taking into account that
89-
// multiple platforms may map to a single module (e.g. pwabuilder-cordova => android, ios, windows...)
9081
var tasks = (platforms || []).reduce(function (taskList, platformId) {
9182

92-
// ensure that the platform is registered and is assigned a package name
9383
var platformInfo = platformConfiguration[platformId];
9484
if (platformInfo && platformInfo.packageName) {
9585
var packageName = platformInfo.packageName;
9686

97-
// check if the module has already been loaded
9887
var platformList = platformMap[packageName];
9988

10089
if (!platformList) {
10190

102-
// create a new task to load the platform module
10391
platformMap[packageName] = platformList = [];
10492
var task = loadPlatform(packageName, platformInfo.source).then(function(Platform) {
10593
return { packageName: packageName, Platform: Platform, platforms: platformList };
@@ -108,7 +96,6 @@ function loadPlatforms(platforms, config, callback) {
10896
taskList.push(task);
10997
}
11098

111-
// assign the current platform to the module
11299
platformList.push(platformId);
113100
}
114101
else {
@@ -118,14 +105,11 @@ function loadPlatforms(platforms, config, callback) {
118105
return taskList;
119106
}, []);
120107

121-
// launch the installation of all queued packages
122108
packageTools.installQueuedPackages();
123109

124-
// wait for all modules to load
125110
return Q.allSettled(tasks).then(function (results) {
126111
return results.reduce(function (modules, result) {
127112
if (result.state === 'fulfilled') {
128-
// create instances of each platform module
129113
var module = result.value;
130114
modules.push(new module.Platform(module.packageName, module.platforms));
131115
}
@@ -136,25 +120,19 @@ function loadPlatforms(platforms, config, callback) {
136120
.nodeify(callback);
137121
}
138122

139-
// get the platform package information (package.json)
140123
function getPlatformPackageInfo (id, callback) {
141-
/* jshint unused: vars */
142-
// check if package is in the npm registry
143124
return packageTools.getNpmPackageInfo(id).catch(function (err) {
144125
log.debug('Failed to locate the plaform package in the npm registry...');
145-
// check if package is in a GitHub repository
146126
return packageTools.getGitHubPackageInformation(id);
147127
})
148128
.catch(function (err) {
149129
log.debug('Failed to locate the plaform package in GitHub...');
150130
try {
151-
// check if package is in a local path
152131
return packageTools.getModuleInformation(id);
153132
}
154133
catch (err) {
155134
log.debug('Failed to locate the plaform package in the local disk...');
156135
try {
157-
// check if package is in an installed module
158136
return packageTools.getPackageInformation(id);
159137
}
160138
catch (err) {
@@ -212,15 +190,12 @@ function removePlatform(platformId, configPath, callback) {
212190
}
213191

214192
function getConfiguredPlatforms(configPath) {
215-
// if configurePlatforms has not been called yet, loads the default configuration
216193
configurePlatforms(configPath || platformConfiguration);
217194

218-
// return all registered platforms
219195
return platformConfiguration;
220196
}
221197

222198
function listPlatforms(configPath) {
223-
// return all registered platforms
224199
return Object.keys(getConfiguredPlatforms(configPath));
225200
}
226201

0 commit comments

Comments
 (0)