Skip to content

Commit

Permalink
style: make jshint happy panda
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtajina committed Mar 1, 2013
1 parent 91c1b16 commit 9865bfe
Show file tree
Hide file tree
Showing 17 changed files with 75 additions and 59 deletions.
44 changes: 22 additions & 22 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,28 +130,28 @@ exports.process = function() {
};

switch (options.cmd) {
case 'start':
describeStart();
break;

case 'run':
describeRun();
break;

case 'init':
describeInit();
break;

default:
describeShared();
if (!options.cmd) {
processArgs(argv, options);
console.error('Command not specified.');
} else {
console.error('Unknown command "' + options.cmd + '".');
}
optimist.showHelp();
process.exit(1);
case 'start':
describeStart();
break;

case 'run':
describeRun();
break;

case 'init':
describeInit();
break;

default:
describeShared();
if (!options.cmd) {
processArgs(argv, options);
console.error('Command not specified.');
} else {
console.error('Unknown command "' + options.cmd + '".');
}
optimist.showHelp();
process.exit(1);
}

return processArgs(argv, options);
Expand Down
1 change: 0 additions & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ var normalizeConfig = function(config) {


var readConfigFile = function(filepath) {
var ADAPTER_DIR = __dirname + '/../adapter';
var configEnv = {
// constants
LOG_DISABLE: constant.LOG_DISABLE,
Expand Down
3 changes: 2 additions & 1 deletion lib/file-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ var List = function(patterns, excludes, emitter, preprocess) {
// sorry, this callback is just for easier testing
done = done || function() {};

outer: for (i = 0; i < buckets.length; i++) {
outer:
for (i = 0; i < buckets.length; i++) {
for (j = 0; j < buckets[i].length; j++) {
if (buckets[i][j].originalPath === path) {
break outer;
Expand Down
17 changes: 12 additions & 5 deletions lib/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ var validateBrowser = function(value) {
var envCmd = process.env[proto.ENV_CMD];

if (!fs.existsSync(defaultCmd) && (!envCmd || !fs.existsSync(envCmd))) {
log.warn('No binary for ' + value + '.' + '\n Create symlink at "' + defaultCmd + '", or set "' + proto.ENV_CMD + '" env variable.\n' + colors.NYAN);
log.warn('No binary for %s.\n Create symlink at "%s", or set "%s" env variable.\n' +
colors.NYAN, value, defaultCmd, proto.ENV_CMD);
}
};

Expand All @@ -69,7 +70,8 @@ var questions = [{
}, {
id: 'requirejs',
question: 'Do you want to use Require.js ?',
hint: 'This will add Require.js adapter into files.\nPress tab to list possible options. Enter to move to the next question.',
hint: 'This will add Require.js adapter into files.\n' +
'Press tab to list possible options. Enter to move to the next question.',
options: ['no', 'yes'],
boolean: true
}, {
Expand All @@ -82,20 +84,25 @@ var questions = [{
}, {
id: 'includedFiles',
question: 'Which files do you want to include with <script> tag ?',
hint: 'This should be a script that bootstraps your test by configuring Require.js and kicking __testacular__.start()\nYou can use glob patterns, eg. "js/*.js" or "test/**/*Spec.js".\nEnter empty string to move to the next question.',
hint: 'This should be a script that bootstraps your test by configuring Require.js and ' +
'kicking __testacular__.start()\n' +
'You can use glob patterns, eg. "js/*.js" or "test/**/*Spec.js".\n' +
'Enter empty string to move to the next question.',
multiple: true,
validate: validatePattern,
condition: function(answers) {return answers.requirejs;}
}, {
id: 'files',
question: 'Which files do you want to test ?',
hint: 'You can use glob patterns, eg. "js/*.js" or "test/**/*Spec.js".\nEnter empty string to move to the next question.',
hint: 'You can use glob patterns, eg. "js/*.js" or "test/**/*Spec.js".\n' +
'Enter empty string to move to the next question.',
multiple: true,
validate: validatePattern
}, {
id: 'exclude',
question: 'Any files you want to exclude ?',
hint: 'You can use glob patterns, eg. "**/*.swp".\nEnter empty string to move to the next question.',
hint: 'You can use glob patterns, eg. "**/*.swp".\n' +
'Enter empty string to move to the next question.',
multiple: true,
validate: validatePattern
}, {
Expand Down
5 changes: 3 additions & 2 deletions lib/preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ var createPreprocessor = function(config, basePath, injector) {
return fs.readFile(file.originalPath, function(err, buffer) {
// TODO(vojta): extract get/create temp dir somewhere else (use the same for launchers etc)
var env = process.env;
file.contentPath = (env.TMPDIR || env.TMP || env.TEMP || '/tmp') + '/' + sha1(file.originalPath) + '.js';
var tmp = env.TMPDIR || env.TMP || env.TEMP || '/tmp';
file.contentPath = tmp + '/' + sha1(file.originalPath) + '.js';

processor(buffer.toString(), file, function(processed) {
fs.writeFile(file.contentPath, processed, function(err) {
fs.writeFile(file.contentPath, processed, function() {
done();
});
});
Expand Down
4 changes: 2 additions & 2 deletions lib/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ var createProxyHandler = function(proxy, proxyConfig) {
return next();
};
}
proxy.on('proxyError', function(err, req, resp) {
proxy.on('proxyError', function(err, req) {
if (err.code === 'ECONNRESET' && req.socket.destroyed) {
log.debug('failed to proxy %s (browser hang up the socket)', req.url);
} else {
Expand All @@ -73,7 +73,7 @@ var createProxyHandler = function(proxy, proxyConfig) {
if (request.url.indexOf(proxiesList[i]) === 0) {
var proxiedUrl = proxies[proxiesList[i]];

log.debug('Proxying request - ' + request.url + ' to ' + proxiedUrl.host + ':' + proxiedUrl.port);
log.debug('proxying request - %s to %s:%s', request.url, proxiedUrl.host, proxiedUrl.port);
request.url = request.url.replace(proxiesList[i], proxiedUrl.baseProxyUrl);
proxy.proxyRequest(request, response, {host: proxiedUrl.host, port: proxiedUrl.port});
return;
Expand Down
2 changes: 1 addition & 1 deletion lib/reporters/BaseColor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var colors = require('colors');
require('colors');

var BaseColorReporter = function() {
this.USE_COLORS = true;
Expand Down
4 changes: 2 additions & 2 deletions lib/reporters/Progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ var ProgressReporter = function(formatError, reportSlow) {
};


this.specSuccess = function(browser) {
this.specSuccess = function() {
this.write(this._refresh());
};


this.onBrowserComplete = function(browser) {
this.onBrowserComplete = function() {
this.write(this._refresh());
};

Expand Down
16 changes: 10 additions & 6 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ var start = function(injector, config, launcher, globalEmitter, preprocess, file
});

webServer.listen(config.port, function() {
log.info('Testacular server started at http://' + config.hostname + ':' + config.port + config.urlRoot);
log.info('Testacular server started at http://%s:%s%s', config.hostname, config.port,
config.urlRoot);

if (config.browsers && config.browsers.length) {
injector.invoke(launcher.launch, launcher);
Expand Down Expand Up @@ -89,7 +90,8 @@ var start = function(injector, config, launcher, globalEmitter, preprocess, file
var nonReady = [];

if (!capturedBrowsers.length) {
log.warn('No captured browser, open http://' + config.hostname + ':' + config.port + config.urlRoot);
log.warn('No captured browser, open http://%s:%s%s', config.hostname, config.port,
config.urlRoot);
return false;
} else if (capturedBrowsers.areAllReady(nonReady)) {
log.debug('All browsers are ready, executing');
Expand All @@ -108,7 +110,7 @@ var start = function(injector, config, launcher, globalEmitter, preprocess, file
}
};

globalEmitter.on('browser_complete', function(browser) {
globalEmitter.on('browser_complete', function() {
pendingCount--;

if (!pendingCount) {
Expand All @@ -118,7 +120,7 @@ var start = function(injector, config, launcher, globalEmitter, preprocess, file

globalEmitter.on('run_complete', function(browsers, results) {
if (config.singleRun) {
disconnectBrowsers(results.exitCode);
disconnectBrowsers(results.exitCode);
} else if (executionScheduled) {
tryExecution();
}
Expand All @@ -141,8 +143,10 @@ var start = function(injector, config, launcher, globalEmitter, preprocess, file
log.debug('Execution (fired by runner)');

if (!capturedBrowsers.length) {
log.warn('No captured browser, open http://' + config.hostname + ':' + config.port + config.urlRoot);
socket.end('No captured browser, open http://' + config.hostname + ':' + config.port + config.urlRoot + '\n');
var url = 'http://' + config.hostname + ':' + config.port + config.urlRoot;

log.warn('No captured browser, open ' + url);
socket.end('No captured browser, open ' + url + '\n');
return;
}

Expand Down
11 changes: 7 additions & 4 deletions lib/web-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ var serveStaticFile = function(file, response, process) {
};


var createTestacularSourceHandler = function(promiseContainer, staticFolder, adapterFolder, baseFolder, urlRoot) {
var createTestacularSourceHandler = function(promiseContainer, staticFolder, adapterFolder,
baseFolder, urlRoot) {
return function(request, response, next) {
var requestUrl = request.url.replace(/\?.*/, '');

Expand All @@ -64,7 +65,7 @@ var createTestacularSourceHandler = function(promiseContainer, staticFolder, ada

// SERVE testacular.js
if (requestUrl === '/testacular.js') {
return serveStaticFile(staticFolder + '/testacular.js', response, function(data, response) {
return serveStaticFile(staticFolder + '/testacular.js', response, function(data) {
return data.replace('%TESTACULAR_SRC_PREFIX%', urlRoot.substring(1));
});
}
Expand Down Expand Up @@ -171,8 +172,10 @@ var createSourceFileHandler = function(promiseContainer, adapterFolder, baseFold
};


var createHandler = function(promiseContainer, staticFolder, adapterFolder, baseFolder, proxyFn, proxies, urlRoot) {
var testacularSrcHandler = createTestacularSourceHandler(promiseContainer, staticFolder, adapterFolder, baseFolder, urlRoot);
var createHandler = function(promiseContainer, staticFolder, adapterFolder, baseFolder, proxyFn,
proxies, urlRoot) {
var testacularSrcHandler = createTestacularSourceHandler(promiseContainer, staticFolder,
adapterFolder, baseFolder, urlRoot);
var proxiedPathsHandler = proxy.createProxyHandler(proxyFn, proxies);
var sourceFileHandler = createSourceFileHandler(promiseContainer, adapterFolder, baseFolder);

Expand Down
1 change: 1 addition & 0 deletions static/testacular.src.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ socket.on('reconnecting', updateStatus('reconnecting in $ ms...'));
socket.on('reconnect', updateStatus('re-connected'));
socket.on('reconnect_failed', updateStatus('failed to reconnect'));

/* jshint unused: false */
var Testacular = function(socket, context, navigator, location) {
var config;
var hasError = false;
Expand Down
9 changes: 6 additions & 3 deletions tasks/bump.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ module.exports = function(grunt) {
* grunt bump:minor
* grunt bump:major
*/
grunt.registerTask('bump', 'Increment version, generate changelog, create tag and push to github.', function(type) {
var DESC = 'Increment version, generate changelog, create tag and push to github.';
grunt.registerTask('bump', DESC, function(type) {

var finish = this.async();
var queue = [];
Expand Down Expand Up @@ -62,8 +63,10 @@ module.exports = function(grunt) {
});

run('sublime -w CHANGELOG.md', 'CHANGELOG.md updated');
run('git commit package.json CHANGELOG.md -m "chore: release v' + newVersion + '"', 'Changes committed');
run('git tag -a v' + newVersion + ' -m "Version ' + newVersion + '"', 'New tag "v' + newVersion + '" created');
run('git commit package.json CHANGELOG.md -m "chore: release v' + newVersion + '"',
'Changes committed');
run('git tag -a v' + newVersion + ' -m "Version ' + newVersion + '"', 'New tag "v' +
newVersion + '" created');
run('git push upstream master --tags', 'Pushed to github');
});

Expand Down
2 changes: 1 addition & 1 deletion tasks/contributors.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = function(grunt) {
grunt.registerTask('contributors', 'Update contributors in package.json', function() {
var done = this.async();

exec('git log --pretty=short | git shortlog -nse', function(err, stdout, stderr) {
exec('git log --pretty=short | git shortlog -nse', function(err, stdout) {
var pkgFile = grunt.config('pkgFile');
var pkg = grunt.file.readJSON(pkgFile);

Expand Down
5 changes: 2 additions & 3 deletions tasks/lib/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// TODO(vojta): use grunt logger

var child = require('child_process');
var fs = require('fs');
var util = require('util');
var q = require('qq');

Expand Down Expand Up @@ -138,7 +137,7 @@ var readGitLog = function(grep, from) {
var deffered = q.defer();

// TODO(vojta): if it's slow, use spawn and stream it instead
child.exec(util.format(GIT_LOG_CMD, grep, '%H%n%s%n%b%n==END==', from), function(code, stdout, stderr) {
child.exec(util.format(GIT_LOG_CMD, grep, '%H%n%s%n%b%n==END==', from), function(code, stdout) {
var commits = [];

stdout.split('\n==END==\n').forEach(function(rawCommit) {
Expand Down Expand Up @@ -191,7 +190,7 @@ var writeChangelog = function(stream, commits, version) {

var getPreviousTag = function() {
var deffered = q.defer();
child.exec(GIT_TAG_CMD, function(code, stdout, stderr) {
child.exec(GIT_TAG_CMD, function(code, stdout) {
if (code) {
deffered.reject('Cannot get the previous tag.');
}
Expand Down
3 changes: 0 additions & 3 deletions tasks/lib/validate-commit-msg.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ var TYPES = {

var error = function() {
// gitx does not display it
// http://gitx.lighthouseapp.com/projects/17830/tickets/294-feature-display-hook-error-message-when-hook-fails
// https://groups.google.com/group/gitx/browse_thread/thread/a03bcab60844b812
console.error('INVALID COMMIT MSG: ' + util.format.apply(null, arguments));
};
Expand All @@ -56,8 +55,6 @@ var validateMessage = function(message) {
}

var type = match[1];
var scope = match[3];
var subject = match[4];

if (!TYPES.hasOwnProperty(type)) {
error('"%s" is not allowed type !', type);
Expand Down
4 changes: 2 additions & 2 deletions tasks/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ module.exports = function(grunt) {
var minor = parseInt(pkg.version.split('.')[1], 10);
var tag = (minor % 2) ? 'canary' : 'latest';

exec('git status -s', function(err, stdout, stderr) {
exec('git status -s', function(err, stdout) {
if (stdout) {
return grunt.fail.warn('Dirty workspace, cannot push to NPM.\n' + stdout + '\n');
}

exec('npm publish --tag ' + tag, function(err, output, error) {
exec('npm publish --tag ' + tag, function(err) {
if (err) {
return grunt.fail.fatal(err.message.replace(/\n$/, '.'));
}
Expand Down
3 changes: 2 additions & 1 deletion tasks/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ module.exports = function(grunt) {
if (args[1]) {
if (args[1] === 'test/e2e/angular-scenario/testacular.conf.js') {
processToKill = grunt.util.spawn({
cmd: node, args: ['test/e2e/angular-scenario/server.js']
cmd: node,
args: ['test/e2e/angular-scenario/server.js']
}, function() {});
}

Expand Down

0 comments on commit 9865bfe

Please sign in to comment.