Permalink
Browse files

Version bump to 0.2.0 - JShint now in place

 - All code is now linted
 - Initial grunt.js config added
  • Loading branch information...
1 parent fe7197b commit 2501a94d40a914352d2cf791f9040cce6758b128 @deefour committed Nov 16, 2012
View
@@ -158,7 +158,14 @@ This command obeys the following logic
## Changelog
-### Version 0.1.0 - November 13 2012
+### Version 0.2.0 - November 15 2012
+
+JShint now in place
+
+ - All code is now linted
+ - Initial grunt.js config added
+
+### Version 0.1.0 - November 15 2012
Initial project release
View
@@ -0,0 +1,39 @@
+module.exports = function(grunt) {
+ "use strict";
+
+ // Project configuration.
+ grunt.initConfig({
+ qunit: {
+ files: ['test/**/*.htm']
+ },
+ lint: {
+ files: ['grunt.js', 'lib/**/*.js', 'test/**/*.js']
+ },
+ watch: {
+ files: '<config:lint.files>',
+ tasks: 'lint'// qunit'
+ },
+ jshint: {
+ options: {
+ curly: true,
+ eqeqeq: true,
+ immed: true,
+ latedef: true,
+ newcap: true,
+ noarg: true,
+ sub: true,
+ undef: true,
+ boss: true,
+ eqnull: true,
+ node: true
+ },
+ globals: {
+ jQuery: true
+ }
+ }
+ });
+
+ // Default task.
+ grunt.registerTask('default', 'lint');
+
+};
View
@@ -1,16 +1,18 @@
+"use strict";
+
var flatiron = require('flatiron'),
- colors = require('colors')
+ colors = require('colors'),
path = require('path'),
util = require('utile'),
_ = require('lodash'),
- appName = require('./package.json').name;
+ appName = require('../package.json').name;
var app = module.exports = flatiron.app;
// Set $HOME properly for windows
-if (process.platform == "win32") {
+if (process.platform === "win32") {
process.env.HOME = process.env.USERPROFILE;
}
@@ -19,27 +21,24 @@ if (process.platform == "win32") {
// Setup some basic options/usage instructions for flatiron
// an the related cli plugin
app.use(flatiron.plugins.cli, {
- dir: path.join(__dirname, 'lib', 'commands'),
+ dir: path.join(__dirname, 'commands'),
argv: {
- usage: [
- 'mm'
- ],
+ usage: [''],
colors: {
description: '--no-colors will disable output coloring',
- default: true,
+ 'default': true,
boolean: true
},
notFoundUsage: []
}
});
-defaults = {
+app.config.file({ file: path.join(__dirname, util.format('%s-config.json', appName)) });
+app.config.defaults({
'currentGroup': 'default',
'storageFile': path.join(process.env.HOME, util.format('.%s.json', appName)),
'tmpDirFile': '/tmp/speed-dial'
-};
-app.config.file({ file: path.join(__dirname, util.format('%s-config.json', appName)) });
-app.config.defaults(defaults);
+});
app.use(require('flatiron-cli-config'), {
store: 'file',
@@ -69,7 +68,7 @@ app.prompt.properties = flatiron.common.mixin(
message: 'Are you sure?',
validator: /y[es]*|n[o]?/,
warning: 'Must respond yes or no',
- default: 'no'
+ 'default': 'no'
}
}
);
@@ -81,9 +80,11 @@ app.prompt.override = app.argv;
// Startup the flatiron app
app.start = function(callback) {
// Allow coloring in the console output to be disabled
- var useColors = (typeof app.argv.colors == 'undefined' || app.argv.colors);
+ var useColors = (typeof app.argv.colors === 'undefined' || app.argv.colors);
- useColors || (colors.mode = "none");
+ if (!useColors) {
+ colors.mode = "none";
+ }
app.init(function(err) {
if (!useColors) {
@@ -107,9 +108,13 @@ app.exec = function (command, callback) {
app.router.dispatch('on', command.join(' '), app.log, function (err, shallow) {
if (err) {
app.log.error(err.message);
- if (!_.isUndefined(callback)) callback(err);
+ if (!_.isUndefined(callback)) {
+ callback(err);
+ }
}
- if (!_.isUndefined(callback)) callback(err);
+ if (!_.isUndefined(callback)) {
+ callback(err);
+ }
});
-}
+};
View
@@ -1,4 +1,6 @@
-var app = module.exports = require('../app'),
+"use strict";
+
+var app = module.exports = require('./app'),
storage = require('./storage');
@@ -7,6 +9,8 @@ var app = module.exports = require('../app'),
storage.load(
app.config.get('storageFile'),
function(err) {
- if (err) throw err;
+ if (err) {
+ throw err;
+ }
}
);
View
@@ -1,6 +1,6 @@
var support = require('../support'),
storage = require('../storage'),
- app = require('../../app'),
+ app = require('../app'),
fs = require('fs'),
util = require('utile'),
_ = require('lodash'),
@@ -14,6 +14,8 @@ var support = require('../support'),
* The entry doesn't require an alias.
*/
var add = module.exports = function(dir, alias, callback) {
+ "use strict";
+
// Initialize
var groupName = app.argv.group || app.config.get('currentGroup'),
weight = app.argv.weight || 0,
@@ -1,5 +1,5 @@
var storage = require('../storage'),
- app = require('../../app'),
+ app = require('../app'),
util = require('utile'),
_ = require('lodash');
@@ -9,6 +9,8 @@ var storage = require('../storage'),
* Adds a new listing to the storage. Expects a path and an alias.
*/
var addlisting = module.exports = function(path, alias, callback) {
+ "use strict";
+
// Initialize
var weight = app.argv.weight || 0,
listing = { path: path, alias: alias, weight: weight },
View
@@ -1,7 +1,7 @@
var commands = module.exports;
var support = require('../support'),
- app = require('../../app'),
+ app = require('../app'),
util = require('utile'),
list = require('./list'),
phpjs = require('phpjs'),
@@ -28,9 +28,11 @@ var support = require('../support'),
* will catch and
*/
var go = module.exports = function(group, alias, callback) {
+ "use strict";
+
// Initialize
var key = 'Entry/Listing ID',
- entry;
+ entryResult;
// Allow for arbitrary number of arguments
if (alias === null) {
@@ -45,7 +47,7 @@ var go = module.exports = function(group, alias, callback) {
* for the bash script to read
*/
var writeTarget = function(result, output) {
- fs.open(app.config.get('tmpDirFile'), 'w+', 0666, function(e, id) {
+ fs.open(app.config.get('tmpDirFile'), 'w+', 666, function(e, id) {
fs.write( id, result.entry.path, null, 'utf8', function(){
fs.close(id, function(){
if (_.isUndefined(output)) {
@@ -74,7 +76,7 @@ var go = module.exports = function(group, alias, callback) {
number, result;
_.each(list, function(filename) {
- file = support.normalizePath(dir + '/' + filename);
+ var file = support.normalizePath(dir + '/' + filename);
if (fs.statSync(file).isDirectory()) {
if (++i === +index) {
result = {file: filename, path: file};
@@ -96,7 +98,7 @@ var go = module.exports = function(group, alias, callback) {
askGroup = function(group, callback){
list(group, {
'single-listing': true,
- 'exit-if-empty': true,
+ 'exit-if-empty': true
});
var key = 'Directory alias or ID';
@@ -110,7 +112,9 @@ var go = module.exports = function(group, alias, callback) {
return support.hasEntry(group, id);
}
}], function(err, result) {
- if (err) return;
+ if (err) {
+ return callback(err);
+ }
support.withEntry(group, result[key], function(entryResult) {
if (!_.isUndefined(callback)) {
@@ -143,7 +147,9 @@ var go = module.exports = function(group, alias, callback) {
return !_.isUndefined(listingChildren(entryResult.entry.path, id));
}
}], function(err, result) {
- if (err) return;
+ if (err) {
+ return callback(err);
+ }
var target = listingChildren(entryResult.entry.path, result[key]);
writeTarget({ entry: { path: target.path }}, util.format('The %s directory, a child of %s, the %s with alias %s, has been selected', target.file.yellow.bold, entryResult.entry.path.yellow.bold, 'listing'.yellow.bold, entryResult.entry.alias.yellow.bold));
@@ -156,7 +162,7 @@ var go = module.exports = function(group, alias, callback) {
if (!_.isString(alias)) { // no args passed; print a single listing of everything and prompt for an id
list({
'single-listing': true,
- 'exit-if-empty': true,
+ 'exit-if-empty': true
});
app.prompt.get([{
@@ -168,7 +174,9 @@ var go = module.exports = function(group, alias, callback) {
return support.hasEntry(id);
}
}], function(err, result) {
- if (err) return;
+ if (err) {
+ return callback(err);
+ }
entryResult = support.withEntry(result[key]);
View
@@ -1,5 +1,5 @@
var storage = require('../storage'),
- app = require('../../app'),
+ app = require('../app'),
util = require('utile'),
_ = require('lodash');
@@ -10,6 +10,8 @@ var storage = require('../storage'),
* Sets the passed group as the newly 'current' one.
*/
var group = module.exports = function(group, callback) {
+ "use strict";
+
// The currently active group should be printed
if (!_.isString(group)) {
return app.log.info(util.format('The %s is %s', 'active group'.yellow.bold, app.config.get('currentGroup').yellow.bold));
View
@@ -1,8 +1,6 @@
var support = require('../support'),
- storage = require('../storage'),
- app = require('../../app'),
+ app = require('../app'),
path = require('path'),
- _ = require('lodash'),
fs = require('fs'),
util = require('utile'),
appTitle = require('../../package.json').title,
@@ -17,9 +15,10 @@ var support = require('../support'),
* to enter the file path to append the souce line to.
*/
var init = module.exports = function(id, callback) {
+ "use strict";
+
// Initialize
- var args = app.argv._,
- key = 'File to append souce line';
+ var key = 'File to append souce line';
@@ -48,15 +47,17 @@ var init = module.exports = function(id, callback) {
sourceLine = util.format('. %s', path.join(__dirname, '..', '..', 'assets', 'functions'));
// Explain (warn)
- app.log.warn(util.format('%s will append "%s" to the %s file', appTitle.blue.bold, sourceLine.yellow.bold, filePath.yellow.bold))
+ app.log.warn(util.format('%s will append "%s" to the %s file', appTitle.blue.bold, sourceLine.yellow.bold, filePath.yellow.bold));
// Confirm the filepath & write action
app.prompt.get(['yesno'], function(err, result) {
- if (err) throw err;
+ if (err) {
+ return callback(err);
+ }
if (/^y/i.test(result.yesno)) {
// Perform the append
- fs.open(filePath, 'a+', 0666, function( e, id ) {
+ fs.open(filePath, 'a+', 666, function( e, id ) {
fs.write( id, util.format("\n\n# Loads %s functions\n%s", appTitle, sourceLine), null, 'utf8', function(){
fs.close(id, function(){
// Explain everything went well
View
@@ -1,6 +1,6 @@
var support = require('../support'),
storage = require('../storage'),
- app = require('../../app'),
+ app = require('../app'),
prettyjson = require('prettyjson'),
_ = require('lodash'),
phpjs = require('phpjs'),
@@ -19,6 +19,8 @@ var support = require('../support'),
* - One contiguous index spanning groups/listings (used for deletion)
*/
var list = module.exports = function(name, options, callback) {
+ "use strict";
+
// Initialize functions
var _getLine = function(entry, i, internalPointer, useInternalPointer) {
var number;
@@ -80,7 +82,7 @@ var list = module.exports = function(name, options, callback) {
// Initialize variables/defaults
var internalPointer = 0,
- useInternalPointer = options['single-listing'] == true;
+ useInternalPointer = options['single-listing'] === true;
Oops, something went wrong.

0 comments on commit 2501a94

Please sign in to comment.