Permalink
Browse files

Added jshint config file and linted the code

  • Loading branch information...
1 parent ceca69f commit 4a6b81bc3883cdb1c57c470833ab76a6f3e9489c @laktek committed Aug 24, 2012
Showing with 1,405 additions and 1,337 deletions.
  1. +43 −0 .jshintrc
  2. +28 −28 lib/asset_bundler.js
  3. +37 −33 lib/cache_store.js
  4. +32 −31 lib/cli.js
  5. +1 −1 lib/compilers/coffee_script.js
  6. +4 −3 lib/compilers/less.js
  7. +24 −23 lib/config_handler.js
  8. +58 −59 lib/content_handler.js
  9. +19 −19 lib/default_config.js
  10. +4 −2 lib/generator_hooks/console_output.js
  11. +14 −14 lib/helpers/asset_bundle_helper.js
  12. +10 −9 lib/helpers/datetime_helper.js
  13. +9 −10 lib/helpers/list_helper.js
  14. +20 −19 lib/helpers/text_helper.js
  15. +1 −2 lib/minifiers/cssmin.js
  16. +2 −4 lib/minifiers/uglify.js
  17. +49 −48 lib/page_renderer.js
  18. +29 −22 lib/page_server.js
  19. +5 −4 lib/parsers/markdown.js
  20. +9 −11 lib/publisher.js
  21. +18 −17 lib/publishers/s3.js
  22. +26 −22 lib/publishers/sftp.js
  23. +2 −3 lib/server.js
  24. +15 −16 lib/setup.js
  25. +42 −37 lib/site_generator.js
  26. +18 −16 lib/template_engines/base_engine.js
  27. +8 −8 lib/template_engines/mustache_engine.js
  28. +50 −50 lib/template_handler.js
  29. +14 −14 lib/utils/deep_extend.js
  30. +15 −14 lib/utils/deep_fstream.js
  31. +10 −8 lib/utils/helper_utils.js
  32. +5 −4 lib/utils/module_utils.js
  33. +6 −6 lib/utils/path_utils.js
  34. +3 −3 package.json
  35. +79 −79 spec/asset_bundler.spec.js
  36. +41 −41 spec/cache_store.spec.js
  37. +13 −15 spec/cli.spec.js
  38. +2 −2 spec/compilers/coffee_script.spec.js
  39. +27 −27 spec/config_handler.spec.js
  40. +67 −67 spec/content_handler.spec.js
  41. +4 −4 spec/helpers/asset_bundle_helper.spec.js
  42. +12 −12 spec/helpers/list_helper.spec.js
  43. +2 −2 spec/minifiers/cssmin.spec.js
  44. +5 −5 spec/minifiers/uglify.spec.js
  45. +113 −113 spec/page_renderer.spec.js
  46. +92 −94 spec/page_server.spec.js
  47. +2 −2 spec/parsers/markdown.spec.js
  48. +21 −21 spec/publisher.spec.js
  49. +15 −15 spec/publishers/s3.spec.js
  50. +30 −30 spec/publishers/sftp.spec.js
  51. +3 −3 spec/server.spec.js
  52. +17 −17 spec/setup.spec.js
  53. +83 −83 spec/site_generator.spec.js
  54. +26 −27 spec/template_engines/base_engine.spec.js
  55. +8 −8 spec/template_engines/mustache_engine.spec.js
  56. +99 −99 spec/template_handler.spec.js
  57. +14 −11 spec/utils/deep_fstream.spec.js
View
@@ -0,0 +1,43 @@
+{
+ "predef": [
+ "jasmine",
+ "spyOn",
+ "it",
+ "console",
+ "describe",
+ "expect",
+ "beforeEach",
+ "waits",
+ "waitsFor",
+ "runs"
+ ],
+
+ "node" : true,
+ "es5" : true,
+
+ "curly": true,
+ "debug": false,
+ "devel": false,
+ "eqeqeq": true,
+ "evil": true,
+ "forin": true,
+ "immed": true,
+ "indent": 4,
+ "latedef": true,
+ "lastsemic": true,
+ "newcap": true,
+ "noarg": true,
+ "noempty": false,
+ "nonew": true,
+ "onevar": false,
+ "plusplus": false,
+ "quotmark": "double",
+ "regexp": true,
+ "undef": true,
+ "unused": true,
+ "smarttabs": true,
+ "sub": true,
+ "strict": false,
+ "trailing": false,
+ "white": false
+}
View
@@ -20,19 +20,19 @@ module.exports = {
bundleOptions: {},
bundles: {},
-
+
setup: function(config) {
var self = this;
self.templates = module_utils.requireAndSetup(config.plugins.template_handler, config);
self.cacheStore = module_utils.requireAndSetup(config.plugins.cache_store, config);
_.each(config.plugins.compilers, function(value, key) {
- self.compilers[key] = module_utils.requireAndSetup(value, config);
+ self.compilers[key] = module_utils.requireAndSetup(value, config);
});
_.each(config.plugins.minifiers, function(value, key) {
- self.minifiers[key] = module_utils.requireAndSetup(value, config);
+ self.minifiers[key] = module_utils.requireAndSetup(value, config);
});
self.bundles = _.extend(self.bundles, config.bundles);
@@ -44,7 +44,7 @@ module.exports = {
var self = this;
if (!minifier) {
- return callback("No minifier found", null);
+ return callback("No minifier found", null);
}
var template_extension = path.extname(template_path);
@@ -53,15 +53,15 @@ module.exports = {
if (err) {
return callback(err, null);
}
-
+
if (compiler && compiler.input_extensions.indexOf(template_extension) > -1) {
compiler.compile(template_output, path.join(self.templates.templateDir, template_path), function(err, compiled_output) {
if(err) {
return callback(err, null);
- }
+ }
return minifier.minify(compiled_output, callback);
- });
+ });
} else {
return minifier.minify(template_output, callback);
}
@@ -89,11 +89,11 @@ module.exports = {
} else {
return callback(minified_outputs.join(""));
}
- }
+ };
+
+ return fetch_compile_and_minify();
+ },
- return fetch_compile_and_minify();
- },
-
getBundle: function(request_basename, file_extension, callback) {
var self = this;
var bundle_name = withoutTimestamp(request_basename);
@@ -111,14 +111,14 @@ module.exports = {
return self.cacheStore.update(bundle_name, file_extension, minified_output, bundle_header, function(err, cache_obj){
bundle_options.header = cache_obj.options.header;
return callback(null, { "body": minified_output, "modified": true, "options": bundle_options });
- });
+ });
});
- }
+ };
self.cacheStore.stat(bundle_name, file_extension, function(err, stat) {
if (err) {
- return prepare_bundle_and_update_cache();
- }
+ return prepare_bundle_and_update_cache();
+ }
var cloned_bundle_files = bundle.slice(0);
@@ -130,18 +130,18 @@ module.exports = {
}
if (template.last_modified > stat.mtime) {
- return prepare_bundle_and_update_cache();
+ return prepare_bundle_and_update_cache();
} else {
- return check_for_modified();
+ return check_for_modified();
}
});
} else {
return self.cacheStore.get(bundle_name, file_extension, bundle_header, function(err, cache_obj) {
bundle_options.header = cache_obj.options.header;
return callback(null, { "body": cache_obj.body, "modified": false, "options": bundle_options });
- });
+ });
}
- }
+ };
return check_for_modified();
});
@@ -156,7 +156,7 @@ module.exports = {
var extension = path.extname(entry);
var basename = entry.substr(0, entry.indexOf(extension));
- collected_bundles.push([ basename, extension ]);
+ collected_bundles.push([ basename, extension ]);
});
var touch_next_bundle = function() {
@@ -168,27 +168,27 @@ module.exports = {
// this is to let generator hooks to skip callbacks without a path.
var bundle_path = (bundle_obj.modified) ? ( params[0] + params[1] ) : null;
after(bundle_path, function() {
- return touch_next_bundle();
+ return touch_next_bundle();
});
});
- return self.getBundle.apply(self, params);
+ return self.getBundle.apply(self, params);
} else {
- return complete();
+ return complete();
}
- }
+ };
- return touch_next_bundle()
+ return touch_next_bundle();
},
isBundlePath: function(basename, file_extension) {
var self = this;
- var bundle_names = _.keys(self.bundles);
+ var bundle_names = _.keys(self.bundles);
var bundle_path = withoutTimestamp(basename) + file_extension;
- return bundle_names.indexOf(bundle_path) > -1
+ return (bundle_names.indexOf(bundle_path) > -1);
}
-}
+};
View
@@ -1,14 +1,14 @@
var path = require("path");
var fs = require("fs");
-var DeepFstream = require("./utils/deep_fstream");
+var DeepFstream = require("./utils/deep_fstream");
module.exports = {
- outputDir: null,
+ outputDir: null,
//setup the module
setup: function(config){
- var self = this;
+ var self = this;
self.outputDir = config.output_dir;
},
@@ -19,11 +19,11 @@ module.exports = {
fs.stat(file_path, function(err, stat){
if(err){
- return callback(err);
- }
+ return callback(err);
+ }
return callback(null, { "mtime": stat.mtime, "size": stat.size });
- });
+ });
},
get: function(request_basename, file_extension, header, callback){
@@ -34,14 +34,14 @@ module.exports = {
fs.stat(file_path, function(err, stat){
if(err){
- return callback(err, cache_obj);
- }
+ return callback(err, cache_obj);
+ }
fs.readFile(file_path, "binary", function(err, cached_content){
cache_obj.body = cached_content;
cache_obj.options.header["Content-Length"] = (cached_content && cached_content.length || 0);
- cache_obj.options.header["ETag"] = '"' + stat.size + '-' + Number(stat.mtime) + '"'
+ cache_obj.options.header["ETag"] = ("\"" + stat.size + "-" + Number(stat.mtime) + "\"");
cache_obj.options.header["Last-Modified"] = new Date(stat.mtime).toUTCString();
return callback(err, cache_obj);
@@ -59,44 +59,48 @@ module.exports = {
var writeToCache = function() {
fs.writeFile(file_path, body, "binary", function(err){
if (err) {
- return callback(err);
+ return callback(err);
}
self.stat(request_basename, file_extension, function(err, stat){
if (err) {
- return callback(err, null);
+ return callback(err, null);
}
var cache_obj = { "body": body, "options": { "header": header } };
cache_obj.options.header["Content-Length"] = (body && body.length || 0);
- cache_obj.options.header["ETag"] = '"' + stat.size + '-' + Number(stat.mtime) + '"'
+ cache_obj.options.header["ETag"] = ("\"" + stat.size + "-" + Number(stat.mtime) + "\"");
cache_obj.options.header["Last-Modified"] = new Date(stat.mtime).toUTCString();
return callback(err, cache_obj);
});
});
- }
+ };
var checkAndCreateDir = function(dirpath){
fs.stat(dirpath, function(err, stat){
if(err || !stat.isDirectory()){
fs.mkdir(dirpath, function(err){
+ if (err) {
+ throw err;
+ }
+
return checkAndCreateDirCallback(dirpath);
- });
+ });
} else {
return checkAndCreateDirCallback(dirpath);
}
- });
- }
+ });
+ };
var checkAndCreateDirCallback = function(current_path){
if(dir_path_portions.length){
- var next_dirpath = path.join(current_path, dir_path_portions.shift());
+ var next_dirpath = path.join(current_path, dir_path_portions.shift());
return checkAndCreateDir(next_dirpath);
} else {
- return writeToCache();
+ return writeToCache();
}
- }
+ };
checkAndCreateDirCallback("");
},
@@ -110,40 +114,40 @@ module.exports = {
var remove_directories = function(complete) {
if (collected_directories.length) {
fs.rmdir(collected_directories.pop(), function() {
- return remove_directories(complete);
- });
+ return remove_directories(complete);
+ });
} else {
- return complete();
+ return complete();
}
};
var remove_files = function(complete) {
if (collected_files.length) {
return fs.unlink(collected_files.pop(), function() {
- return remove_files(complete);
- });
+ return remove_files(complete);
+ });
} else {
- return complete();
+ return complete();
}
- }
+ };
file_stream.on("directory", function(entry, next) {
var skip = true;
// skip hidden directories
if (entry.basename[0] !== ".") {
- collected_directories.push(entry.path);
+ collected_directories.push(entry.path);
skip = false;
- }
+ }
return next(skip);
});
file_stream.on("file", function(entry, next) {
if (entry.basename[0] !== ".") {
- collected_files.push(entry.path);
+ collected_files.push(entry.path);
}
- return next();
+ return next();
});
file_stream.on("end", function() {
@@ -156,9 +160,9 @@ module.exports = {
// If there's an error in reading the file-stream,
// we assume it doesn't exist yet and move on.
- file_stream.on("error", function(error) {
- return callback();
+ file_stream.on("error", function() {
+ return callback();
});
}
-}
+};
Oops, something went wrong.

0 comments on commit 4a6b81b

Please sign in to comment.