Skip to content

Commit

Permalink
Fix up jshint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
sgtcoolguy committed Aug 4, 2017
1 parent 8151812 commit 2f0827c
Show file tree
Hide file tree
Showing 14 changed files with 140 additions and 132 deletions.
6 changes: 4 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ module.exports = function(grunt) {
options: {
force: false
},
src: ['index.js', 'lib/**/*.js', 'test/*.js', 'hook/**/*.js', 'bin/*']
// Don't lint lib/_head.js or lib/_tail.js because they're fragments
src: ['index.js', 'lib/**/!(_)*.js', 'test/*.js', 'hook/**/*.js', 'bin/*']
},
bump: {
options: {
Expand Down Expand Up @@ -74,7 +75,8 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-mocha-istanbul');

grunt.registerTask('build', ['clean:dist', 'concat:dist', 'uglify:dist']);
grunt.registerTask('test', ['appcJs', 'clean:test', 'mocha_istanbul:coverage']);
grunt.registerTask('lint', ['appcJs']);
grunt.registerTask('test', ['build', 'lint', 'clean:test', 'mocha_istanbul:coverage']);
grunt.registerTask('default', ['build']);

};
18 changes: 9 additions & 9 deletions bin/liveview
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@

require('shelljs/global');

var program = require('commander')
, colors = require('coloring')
, spawn = require('win-fork')
, path = require('path')
, fs = require('fs')
, join = path.join
, exists = fs.existsSync
, pkgConf = require('../package')
, debug = require('debug')('liveview:cli');
var program = require('commander'),
colors = require('coloring'),
spawn = require('win-fork'),
path = require('path'),
fs = require('fs'),
join = path.join,
exists = fs.existsSync,
pkgConf = require('../package'),
debug = require('debug')('liveview:cli');

// usage

Expand Down
12 changes: 5 additions & 7 deletions bin/liveview-help
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@
* Module dependencies.
*/

var program = require('commander')
, colors = require('coloring')
, exec = require('child_process').exec;
var program = require('commander'),
colors = require('coloring'),
exec = require('child_process').exec;

// parse argv

program.parse(process.argv);

// output available commands

var cmd = program.args[0]
? 'liveview ' + program.args[0] + ' --help'
: 'liveview --help';
var cmd = program.args[0] ? 'liveview ' + program.args[0] + ' --help' : 'liveview --help';

exec(cmd, function(err, stdout){
if (err) {
Expand All @@ -25,4 +23,4 @@ exec(cmd, function(err, stdout){
process.exit(127);
}
process.stdout.write(stdout);
});
});
10 changes: 5 additions & 5 deletions bin/liveview-install
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
*/

// inject shelljs to the global scope

/* globals exec */
require('shelljs/global');

var program = require('commander')
, colors = require('coloring')
, path = require('path');
var program = require('commander'),
colors = require('coloring'),
path = require('path');

program.Command.prototype.unknownOption = function(){};

Expand Down Expand Up @@ -58,4 +58,4 @@ function installHook() {
var outcome = (res.code) ? 'not installed'.red : 'installed'.green;
console.log(' Titanium CLI Hook ' + outcome + '\n');
});
}
}
10 changes: 5 additions & 5 deletions bin/liveview-rm
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
*/

// inject shelljs to the global scope

/* globals exec */
require('shelljs/global');

var program = require('commander')
, colors = require('coloring')
, path = require('path');
var program = require('commander'),
colors = require('coloring'),
path = require('path');

program.Command.prototype.unknownOption = function(){};

Expand Down Expand Up @@ -52,4 +52,4 @@ function rmHook() {
var outcome = (res.code) ? 'not removed'.red : 'removed'.green;
console.log(' Titanium CLI Hook ' + outcome + '\n');
});
}
}
10 changes: 5 additions & 5 deletions bin/liveview-run
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
*/

// inject shelljs to the global scope

/* globals exec */
require('shelljs/global');

var program = require('commander')
, colors = require('coloring')
, fserver = require('../lib/fserver');
var program = require('commander'),
colors = require('coloring'),
fserver = require('../lib/fserver');

program.Command.prototype.unknownOption = function(){};

Expand All @@ -22,7 +22,7 @@ program
// examples

program.on('--help', function(){
console.log(' Ti-Options:\n')
console.log(' Ti-Options:\n');
exec('ti build --no-banner --help', {silent:true}).output.split('\n').forEach(function(line){
console.log(' ' + line);
});
Expand Down
43 changes: 24 additions & 19 deletions build/liveview.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
* liveview Titanium CommonJS require with some Node.js love and dirty hacks
* Copyright (c) 2013 Appcelerator
*/
(function(globalScope) {
(function(globalScope) {/* globals Emitter */
/**
* Initialize a new `Process`.
*
* @api public
*/

function Process() {
if (!(this instanceof Process)) return new Process();
if (!(this instanceof Process)) {
return new Process();
}
this.title = 'titanium';
this.version = '';
this.moduleLoadList = [];
Expand All @@ -24,6 +26,7 @@ function Process() {
// inherit from EventEmitter

Process.prototype.__proto__ = Emitter.prototype;

/*!
* Event Emitters
*/
Expand Down Expand Up @@ -109,7 +112,7 @@ Emitter.prototype.off = function(event, fn){
if (!callbacks) { return this; }

// remove all handlers
if (1 == arguments.length) {
if (1 === arguments.length) {
delete this._callbacks[event];
return this;
}
Expand Down Expand Up @@ -168,6 +171,7 @@ Emitter.prototype.listeners = function(event){
Emitter.prototype.hasListeners = function(event){
return !! this.listeners(event).length;
};
/* globals Emitter */
/**
* Expose `Socket`.
*/
Expand Down Expand Up @@ -210,7 +214,7 @@ Socket.prototype.connect = function(opts, fn){
var self = this;
opts = opts || {};
var reConnect = !!opts.reConnect;
if ('function' == typeof opts) {
if ('function' === typeof opts) {
fn = opts;
opts = {};
}
Expand Down Expand Up @@ -264,13 +268,13 @@ Socket.prototype.close = function(serverEnded){
self._proxy.close();
self.emit('close');
});
return
return;
}

var retry = ~~self.retry;

self.emit('end');
if(!retry) { return };
if(!retry) { return; }

setTimeout(function(){
self.emit('reconnecting');
Expand All @@ -280,7 +284,7 @@ Socket.prototype.close = function(serverEnded){


Socket.prototype.write = function(data, fn) {
if ('function' == typeof data) {
if ('function' === typeof data) {
fn = data;
data = null;
}
Expand Down Expand Up @@ -314,6 +318,7 @@ Socket.prototype.setKeepAlive = function(enable, initialDelay) {
self.write('ping');
},initialDelay || 300000);
};
/* globals Process, Socket */

/**
* Initialize a new `Module`.
Expand Down Expand Up @@ -341,7 +346,7 @@ var global = Module._global = Module.global = {};

// main process

var process = global.process = Process();
var process = global.process = new Process();

// set environment type

Expand Down Expand Up @@ -389,8 +394,8 @@ Module._includeNative = function(){

Module.patch = function (globalCtx, url, port) {

var defaultURL = (process.platform === 'android' && process.hardware === 'sdk')
? '10.0.2.2'
var defaultURL = (process.platform === 'android' && process.hardware === 'sdk') ?
'10.0.2.2'
: (Ti.Platform.model === 'Simulator' ? '127.0.0.1' : 'FSERVER_HOST');
Module._globalCtx = globalCtx;
global._globalCtx = globalCtx;
Expand All @@ -407,7 +412,7 @@ Module.patch = function (globalCtx, url, port) {
return (globalCtx.localeStrings[Ti.Locale.currentLanguage] || {})[name] || filler || name;
};
Module.connectServer();
}
};

/**
* [reload description]
Expand Down Expand Up @@ -560,18 +565,18 @@ Module.exists = function(id) {
var path = Ti.Filesystem.resourcesDirectory + id + '.js';
var file = Ti.Filesystem.getFile(path);

if (file.exists()) return true;
if (!this.platform) return false;
if (file.exists()) { return true; }
if (!this.platform) { return false; }
var pFolderPath = Ti.Filesystem.resourcesDirectory + '/' + this.platform + '/' + id + '.js';
var pFile = Ti.Filesystem.getFile(pFolderPath)
var pFile = Ti.Filesystem.getFile(pFolderPath);

return pFile.exists();
};

/**
* shady xhrSync request
*
* @param {String} url
* @param {String} file
* @param {Number} timeout
* @return {String}
* @api private
Expand All @@ -582,9 +587,9 @@ Module.prototype._getRemoteSource = function(file,timeout){
var request = Ti.Network.createHTTPClient();
var rsp = null;
var done = false;
var file = 'http://' + Module._url + ':' + Module._port + '/' + (file || this.id) + '.js';
var url = 'http://' + Module._url + ':' + Module._port + '/' + (file || this.id) + '.js';
request.cache = false;
request.open('GET', file);
request.open('GET', url);
request.setRequestHeader('x-platform', this.platform);
request.send();
while(!done){
Expand Down Expand Up @@ -666,8 +671,8 @@ Module.prototype._compile = function() {
return;
}
this.source = Module._wrap(src);
try{
var fn = Function('exports, require, module, __filename, __dirname, lvGlobal',this.source);
try {
var fn = new Function('exports, require, module, __filename, __dirname, lvGlobal', this.source); // jshint ignore:line
fn(this.exports, Module.require, this, this.filename, this.__dirname, global);
} catch(err) {
process.emit("uncaughtException", {module: this.id, error: err, source: ('' + this.source).split('\n')});
Expand Down
2 changes: 1 addition & 1 deletion build/liveview.min.js

Large diffs are not rendered by default.

19 changes: 11 additions & 8 deletions hook/lvhook.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// inject shelljs to the global scope
/* globals cp, tempdir */
require('shelljs/global');

var debug = require('debug')('liveview:clihook'),
Expand Down Expand Up @@ -33,17 +35,17 @@ exports.init = function(logger, config, cli) {
r.options['liveview-ip'] = {
default: null,
desc: 'LiveView Server IP address'
}
};

r.options['liveview-fport'] = {
default: null,
desc: 'LiveView file server port'
}
};

r.options['liveview-eport'] = {
default: null,
desc: 'LiveView event server port'
}
};

finished(null, data);
}
Expand Down Expand Up @@ -186,7 +188,7 @@ exports.init = function(logger, config, cli) {
binDIR,
'start',
'--project-dir', cli.argv['project-dir'],
'--platform', cli.argv['platform']
'--platform', cli.argv.platform
];

if (!cli.argv.colors) {
Expand Down Expand Up @@ -220,13 +222,14 @@ exports.init = function(logger, config, cli) {
*/
function getNetworkIp() {
var n = require('os').networkInterfaces();
var ip = []
var ip = [];
for (var k in n) {
var inter = n[k]
for (var j in inter)
var inter = n[k];
for (var j in inter) {
if (inter[j].family === 'IPv4' && !inter[j].internal) {
return inter[j].address
return inter[j].address;
}
}
}
}

Expand Down

0 comments on commit 2f0827c

Please sign in to comment.