Skip to content
This repository has been archived by the owner on Apr 11, 2022. It is now read-only.

Commit

Permalink
Fix eslint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
surajpindoria committed Dec 16, 2016
1 parent d0edfd6 commit b3160d1
Show file tree
Hide file tree
Showing 25 changed files with 179 additions and 198 deletions.
1 change: 0 additions & 1 deletion bin/phonegap.js
Expand Up @@ -11,7 +11,6 @@ var version = require('../package.json').version;
var sanitizeArgs = require('../lib/cli/util/sanitize-args');

if (analytics.statusUnknown()) {

// if it is an analytics command, just run it
if (process.argv.length > 2 && process.argv[2] === 'analytics') {
runPhoneGapCommand();
Expand Down
3 changes: 0 additions & 3 deletions lib/cli/analytics.js
Expand Up @@ -47,9 +47,7 @@ var AnalyticsOnMessage = '\nAnalytics is on! Nice, you are helping us improve P
'If you would like to turn analytics off, simply run `phonegap analytics off`\n';



module.exports = function analytics(argv, callback) {

var params = argv._.slice(1);

if (params.length > 0) {
Expand Down Expand Up @@ -105,7 +103,6 @@ module.exports = function analytics(argv, callback) {


module.exports.prompt = function prompt(callback) {

console.log(PromptPreamble);

insight.askPermission(PromptMessage,function(error,optIn) {
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/cordova.js
Expand Up @@ -33,7 +33,7 @@ module.exports = function(argv, callback) {
cordovaCommand = cordovaCommand.map(function(command) {
return (/\s/.test(command)) ? '"' + command + '"' : command;
});

// stop cordova-cli from tracking us!
cordovaCommand.push("--no-telemetry");

Expand Down
2 changes: 1 addition & 1 deletion lib/cli/help.js
Expand Up @@ -35,7 +35,7 @@ module.exports = function(argv, callback) {

// full path
filepath = path.join(basepath, filepath);

// get help info and replace $0 with process name
if (!fs.existsSync(filepath)) {
this.cli.unknown(argv, callback);
Expand Down
20 changes: 10 additions & 10 deletions lib/cli/push.js
Expand Up @@ -16,15 +16,15 @@ var phonegap = require('../main');
*/

module.exports = function(argv, callback) {
// options
var data = {
deviceID: argv.deviceID,
service: argv.service,
payload: argv.payload,
file: argv.file
};
// options
var data = {
deviceID: argv.deviceID,
service: argv.service,
payload: argv.payload,
file: argv.file
};

phonegap.push(data, function(e, server) {
callback(e);
});
phonegap.push(data, function(e, server) {
callback(e);
});
};
4 changes: 2 additions & 2 deletions lib/cli/util/sanitize-args.js
Expand Up @@ -32,7 +32,7 @@ phonegap
// returns an array of args that are switches ex. --target, -d, --verbose
function getSwitches(args) {
return args.filter(function(arg) {
return arg && arg.indexOf("-") === 0;
return arg && arg.indexOf("-") === 0;
});
}

Expand Down Expand Up @@ -133,7 +133,7 @@ module.exports = {
argsToLog.params = subCommand + " count:" + (args.length - 1) + " " + getSwitches(args);
}
break;
}
}
}
}
return argsToLog;
Expand Down
5 changes: 2 additions & 3 deletions lib/phonegap/cordova.js
Expand Up @@ -91,7 +91,6 @@ CordovaCommand.prototype.run = function(options, callback) {
*/

CordovaCommand.prototype.execute = function(options, callback) {

var self = this;

// in order to shell out to the cordova dependency, we must first find
Expand All @@ -107,7 +106,7 @@ CordovaCommand.prototype.execute = function(options, callback) {

// first try to find the cordova binary for npm < 3.x
var binPath = path.resolve(path.join(__dirname, '..', '..', 'node_modules', '.bin'));

// second try to find the cordova binary for npm >= 3.x
if (!fs.existsSync(path.join(binPath, 'cordova'))) {
binPath = path.resolve(path.join(__dirname, '..', '..', '..', '.bin'));
Expand All @@ -117,7 +116,7 @@ CordovaCommand.prototype.execute = function(options, callback) {
if (!fs.existsSync(binPath)) {
binPath = path.resolve(path.join(__dirname, '..', '..', 'node_modules', 'cordova', 'bin'));
}

// Another case where it could be run from an electron spawn
if (!fs.existsSync(binPath)) {
binPath = path.resolve(path.join(__dirname, '..', '..', '..', 'cordova', 'bin'));
Expand Down
26 changes: 13 additions & 13 deletions lib/phonegap/push.js
Expand Up @@ -41,19 +41,19 @@ util.inherits(PushCommand, Command);
*/

PushCommand.prototype.run = function(options, callback) {
// require options
if (!options) throw new Error('requires option parameter');
// require options
if (!options) throw new Error('requires option parameter');

// optional parameters
options.port = options.port || PushServerDefaults.port;
options.host = options.host || PushServerDefaults.host;
options.phonegap = this.phonegap;
callback = callback || function() {};
// optional parameters
options.port = options.port || PushServerDefaults.port;
options.host = options.host || PushServerDefaults.host;
options.phonegap = this.phonegap;
callback = callback || function() {};

// send push
this.execute(options, callback);
// send push
this.execute(options, callback);

return this.phonegap;
return this.phonegap;
};
/*!
* Execute command.
Expand All @@ -63,8 +63,8 @@ PushCommand.prototype.execute = function(options, callback) {
var self = this;

if (options.file) {
var payload = fs.readFileSync(options.file, 'utf8');
options.payload = payload;
var payload = fs.readFileSync(options.file, 'utf8');
options.payload = payload;
}

if (!options.payload) throw new Error('requires payload parameter');
Expand Down Expand Up @@ -93,7 +93,7 @@ PushCommand.prototype.execute = function(options, callback) {
console.log("body: " + chunk);
});
res.on('error', function (e) {
console.log("error: " + e);
console.log("error: " + e);
});
});

Expand Down
2 changes: 1 addition & 1 deletion lib/phonegap/remote.install.js
Expand Up @@ -71,7 +71,7 @@ RemoteInstallCommand.prototype.execute = function(options, callback) {

// change to project directory and delegate errors
if (!project.cd({ emitter: self.phonegap, callback: callback })) return;

// require options.data (for now)
if (!options.data) {
var e = new Error('missing app data');
Expand Down
2 changes: 1 addition & 1 deletion lib/phonegap/remote.run.js
Expand Up @@ -90,7 +90,7 @@ RemoteRunCommand.prototype.execute = function(options, callback) {
var url = 'https://build.phonegap.com' +
data.download[platform.remote] +
'?auth_token=' + configData.phonegap.token;

// output url
self.phonegap.emit('log','url: ' + url);

Expand Down
2 changes: 1 addition & 1 deletion lib/phonegap/util/platform.js
Expand Up @@ -91,7 +91,7 @@ module.exports.supports = function (platforms) {
return true;
}
}
return false
return false;
};

if (!platforms.length) {
Expand Down
14 changes: 7 additions & 7 deletions lib/phonegap/util/project.js
Expand Up @@ -67,7 +67,7 @@ module.exports.cd = function(delegate) {

/**
* Read Phonegap's package.json file and return as an object
*
*
* Options:
*
* - none
Expand All @@ -86,24 +86,24 @@ module.exports.readPackage = function() {
/**
* list installed platforms
*
*
*
* Returns
*
* - {array} containing names of installed platforms
*/
listPlatforms = function () {
var platforms = cdvutil.listPlatforms('.');
return platforms;
return platforms;
};


/**
* check to see if a platform is installed
* check to see if a platform is installed
*
*
*
* Returns
*
* - {boolean} true if platform is installed
* - {boolean} true if platform is installed
*/
checkPlatform = function (plat) {
var detected = listPlatforms();
Expand Down Expand Up @@ -134,7 +134,7 @@ module.exports.isHome = function(homePath) {

module.exports.clobberProjectConfig = function(configPath,clobbertargets) {
var fs = require('fs');

fs.open(configPath,'r+', function(err,fd) {
if (err) {
return;
Expand Down
2 changes: 1 addition & 1 deletion spec/cli/app.spec.js
Expand Up @@ -68,7 +68,7 @@ describe('phonegap app', function() {
argv = ['node', '/usr/local/bin/phonegap'];
spyOn(process.stdout, 'write');
spyOn(phonegap, 'serve').andReturn({
on: function(){}
on: function() {}
});
});

Expand Down
29 changes: 14 additions & 15 deletions spec/cli/help.spec.js
Expand Up @@ -38,22 +38,21 @@ describe('phonegap', function() {
expect(process.stdout.write.mostRecentCall.args[0]).toMatch(/usage:/i);
});

it('should output the help usage information when invoked with help eg $ phonegap help help', function() {
cli.argv(argv.concat(['help', 'help']));
expect(process.stdout.write.mostRecentCall.args[0]).toMatch(/usage:/i);
});

it('should output the help usage information when invoked with help eg $ phonegap help --help', function() {
cli.argv(argv.concat(['help', '--help']));
expect(process.stdout.write.mostRecentCall.args[0]).toMatch(/usage:/i);
});

it('should output the help usage information when invoked with help eg $ phonegap help -h', function() {
cli.argv(argv.concat(['help', '-h']));
expect(process.stdout.write.mostRecentCall.args[0]).toMatch(/usage:/i);
});

it('should output the help usage information when invoked with help eg $ phonegap help help', function() {
cli.argv(argv.concat(['help', 'help']));
expect(process.stdout.write.mostRecentCall.args[0]).toMatch(/usage:/i);
});

it('should output the help usage information when invoked with help eg $ phonegap help --help', function() {
cli.argv(argv.concat(['help', '--help']));
expect(process.stdout.write.mostRecentCall.args[0]).toMatch(/usage:/i);
});

it('should output the help usage information when invoked with help eg $ phonegap help -h', function() {
cli.argv(argv.concat(['help', '-h']));
expect(process.stdout.write.mostRecentCall.args[0]).toMatch(/usage:/i);
});

it('should remove the .js extension from the binary (windows-specific)', function() {
argv = ['node', '/user/local/bin/phonegap.js'];
cli.argv(argv.concat(['help']));
Expand Down
84 changes: 42 additions & 42 deletions spec/cli/remote.login.spec.js
Expand Up @@ -72,63 +72,63 @@ describe('phonegap remote login', function() {
});

describe('$ phonegap remote login', function() {
it('should try to login', function() {
cli.argv(argv.concat(['remote', 'login']));
expect(phonegap.remote.login).toHaveBeenCalledWith(
jasmine.any(Object),
jasmine.any(Function)
);
});
it('should try to login', function() {
cli.argv(argv.concat(['remote', 'login']));
expect(phonegap.remote.login).toHaveBeenCalledWith(
jasmine.any(Object),
jasmine.any(Function)
);
});

describe('successful login', function() {
beforeEach(function() {
phonegap.remote.login.andCallFake(function(argv, callback) {
phonegap.emit('login');
callback(null, {});
});
describe('successful login', function() {
beforeEach(function() {
phonegap.remote.login.andCallFake(function(argv, callback) {
phonegap.emit('login');
callback(null, {});
});
});

it('should prompt for username and password', function() {
cli.argv(argv.concat(['remote', 'login']));
expect(console.prompt).toHaveBeenCalled();
});
it('should prompt for username and password', function() {
cli.argv(argv.concat(['remote', 'login']));
expect(console.prompt).toHaveBeenCalled();
});

it('should trigger callback without an error', function(done) {
cli.argv(argv.concat(['remote', 'login']), function(e, api) {
expect(e).toBeNull();
done();
});
it('should trigger callback without an error', function(done) {
cli.argv(argv.concat(['remote', 'login']), function(e, api) {
expect(e).toBeNull();
done();
});
});

it('should trigger callback with API object', function(done) {
cli.argv(argv.concat(['remote', 'login']), function(e, api) {
expect(api).toBeDefined();
done();
});
it('should trigger callback with API object', function(done) {
cli.argv(argv.concat(['remote', 'login']), function(e, api) {
expect(api).toBeDefined();
done();
});
});
});

describe('failed login', function() {
beforeEach(function() {
phonegap.remote.login.andCallFake(function(argv, callback) {
callback(new Error('Invalid password'));
});
describe('failed login', function() {
beforeEach(function() {
phonegap.remote.login.andCallFake(function(argv, callback) {
callback(new Error('Invalid password'));
});
});

it('should trigger callback with an error', function(done) {
cli.argv(argv.concat(['remote', 'login']), function(e, api) {
expect(e).toBeDefined();
done();
});
it('should trigger callback with an error', function(done) {
cli.argv(argv.concat(['remote', 'login']), function(e, api) {
expect(e).toBeDefined();
done();
});
});

it('should trigger callback without an API object', function(done) {
cli.argv(argv.concat(['remote', 'login']), function(e, api) {
expect(api).not.toBeDefined();
done();
});
it('should trigger callback without an API object', function(done) {
cli.argv(argv.concat(['remote', 'login']), function(e, api) {
expect(api).not.toBeDefined();
done();
});
});
});
});

describe('$ phonegap remote login --username zelda', function() {
Expand Down
2 changes: 1 addition & 1 deletion spec/cli/serve.spec.js
Expand Up @@ -54,7 +54,7 @@ describe('phonegap serve', function() {
argv = ['node', '/usr/local/bin/phonegap'];
spyOn(process.stdout, 'write');
spyOn(phonegap, 'serve').andReturn({
on: function(){}
on: function() {}
});
});

Expand Down

0 comments on commit b3160d1

Please sign in to comment.