Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint everything #710

Merged
merged 4 commits into from
Nov 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@ bin/node_modules/*
bin/templates/project/*
tests/spec/unit/fixtures/*
CordovaLib/cordova.js

# Non-JS binaries
bin/test
bin/cordova_plist_to_config_xml
bin/templates/scripts/cordova/log
bin/templates/scripts/cordova/lib/start-emulator
2 changes: 1 addition & 1 deletion bin/apple_ios_version
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

var versions = require('./templates/scripts/cordova/lib/versions.js');

versions.get_apple_ios_version().done(null, function(err) {
versions.get_apple_ios_version().done(null, function (err) {
console.log(err);
process.exit(2);
});
2 changes: 1 addition & 1 deletion bin/apple_osx_version
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

var versions = require('./templates/scripts/cordova/lib/versions.js');

versions.get_apple_osx_version().done(null, function(err) {
versions.get_apple_osx_version().done(null, function (err) {
console.log(err);
process.exit(2);
});
2 changes: 1 addition & 1 deletion bin/apple_xcode_version
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var versions = require('./templates/scripts/cordova/lib/versions.js');

versions.get_apple_xcode_version().done(function (version) {
console.log(version);
}, function(err) {
}, function (err) {
console.error(err);
process.exit(2);
});
40 changes: 19 additions & 21 deletions bin/autotest
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
#! /usr/bin/env node

#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
/*!
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/



require('nodeunit').reporters.default.run(['bin/tests'])
require('nodeunit').reporters.default.run(['bin/tests']);
8 changes: 4 additions & 4 deletions bin/check_reqs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ var check_reqs = require('./templates/scripts/cordova/lib/check_reqs');
if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) > -1) {
console.log('Usage: check_reqs or node check_reqs');
} else {
check_reqs.run().done(null, function (err) {
console.error('Failed to check requirements due to ' + err);
process.exit(2);
});
check_reqs.run().done(null, function (err) {
console.error('Failed to check requirements due to ' + err);
process.exit(2);
});
}
10 changes: 5 additions & 5 deletions bin/create
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ var ConfigParser = require('cordova-common').ConfigParser;
var Api = require('./templates/scripts/cordova/Api');

var argv = require('nopt')({
'help' : Boolean,
'cli' : Boolean,
'shared' : Boolean, // alias for --link
'link' : Boolean
}, { 'd' : '--verbose' });
'help': Boolean,
'cli': Boolean,
'shared': Boolean, // alias for --link
'link': Boolean
}, { 'd': '--verbose' });

var projectPath = argv.argv.remain[0];

Expand Down
31 changes: 15 additions & 16 deletions bin/templates/scripts/cordova/build
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,20 @@
under the License.
*/

var args = process.argv;
var args = process.argv;
var Api = require('./Api');
var nopt = require('nopt');
var path = require('path');

// Support basic help commands
if(['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) >= 0) {
if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) >= 0) {
require('./lib/build').help();
process.exit(0);
}

// Parse arguments
var buildOpts = nopt({
'verbose' : Boolean,
'silent' : Boolean,
'verbose': Boolean,
'silent': Boolean,
'archs': String,
'debug': Boolean,
'release': Boolean,
Expand All @@ -45,20 +44,20 @@ var buildOpts = nopt({
'automaticProvisioning': Boolean,
'developmentTeam': String,
'packageType': String,
'buildConfig' : String,
'buildFlag' : [String, Array],
'noSign' : Boolean
}, { '-r': '--release', 'd' : '--verbose' }, args);
'buildConfig': String,
'buildFlag': [String, Array],
'noSign': Boolean
}, { '-r': '--release', 'd': '--verbose' }, args);

// Make buildOptions compatible with PlatformApi build method spec
buildOpts.argv = buildOpts.argv.remain;

require('./loggingHelper').adjustLoggerLevel(buildOpts);

new Api().build(buildOpts).done(function() {
console.log('** BUILD SUCCEEDED **');
}, function(err) {
var errorMessage = (err && err.stack) ? err.stack : err;
console.error(errorMessage);
process.exit(2);
});
new Api().build(buildOpts).done(function () {
console.log('** BUILD SUCCEEDED **');
}, function (err) {
var errorMessage = (err && err.stack) ? err.stack : err;
console.error(errorMessage);
process.exit(2);
});
13 changes: 6 additions & 7 deletions bin/templates/scripts/cordova/clean
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,18 @@
*/

var Api = require('./Api');
var path = require('path');
var nopt = require('nopt');

if(['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) >= 0) {
if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) >= 0) {
console.log('Cleans the project directory.');
process.exit(0);
}

// Do some basic argument parsing
var opts = nopt({
'verbose' : Boolean,
'silent' : Boolean
}, { 'd' : '--verbose' });
'verbose': Boolean,
'silent': Boolean
}, { 'd': '--verbose' });

// Make buildOptions compatible with PlatformApi clean method spec
opts.argv = opts.argv.original;
Expand All @@ -42,9 +41,9 @@ opts.noPrepare = true;

require('./loggingHelper').adjustLoggerLevel(opts);

new Api().clean(opts).done(function() {
new Api().clean(opts).done(function () {
console.log('** CLEAN SUCCEEDED **');
}, function(err) {
}, function (err) {
console.error(err);
process.exit(2);
});
33 changes: 16 additions & 17 deletions bin/templates/scripts/cordova/lib/list-devices
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,35 @@
under the License.
*/


var Q = require('q'),
exec = require('child_process').exec;
var Q = require('q');
var exec = require('child_process').exec;

/**
* Gets list of connected iOS devices
* @return {Promise} Promise fulfilled with list of available iOS devices
*/
function listDevices() {
function listDevices () {
var commands = [
Q.nfcall(exec, "ioreg -p IOUSB -l | sed -n -e '/iPad/,/USB Serial Number/p' | grep 'Serial Number' | awk -F\\\" '{print $4 \" iPad\"}'"),
Q.nfcall(exec, "ioreg -p IOUSB -l | sed -n -e '/iPhone/,/USB Serial Number/p' | grep 'Serial Number' | awk -F\\\" '{print $4 \" iPhone\"}'"),
Q.nfcall(exec, "ioreg -p IOUSB -l | sed -n -e '/iPod/,/USB Serial Number/p' | grep 'Serial Number' | awk -F\\\" '{print $4 \" iPod\"}'"),
Q.nfcall(exec, "ioreg -p IOUSB -l | sed -n -e '/iPod/,/USB Serial Number/p' | grep 'Serial Number' | awk -F\\\" '{print $4 \" iPod\"}'")
];

// wrap al lexec calls into promises and wait until they're fullfilled
return Q.all(commands).then(function (results) {
var accumulator = [];
results.forEach(function (result) {
var devicefound;
// Each command promise resolves with array [stout, stderr], and we need stdout only
// Append stdout lines to accumulator
devicefound = result[0].trim().split('\n');
if(devicefound && devicefound.length) {
devicefound.forEach(function(device) {
if (device) {
accumulator.push(device);
}
});
}
var devicefound;
// Each command promise resolves with array [stout, stderr], and we need stdout only
// Append stdout lines to accumulator
devicefound = result[0].trim().split('\n');
if (devicefound && devicefound.length) {
devicefound.forEach(function (device) {
if (device) {
accumulator.push(device);
}
});
}
});
return accumulator;
});
Expand All @@ -64,4 +63,4 @@ if (!module.parent) {
console.log(device);
});
});
}
}
Loading