Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Adds braces and spaces after if #200

Closed
wants to merge 1 commit into from

3 participants

@MiguelMadero

I only changed a handful of files. It's a bit of monkey coding, but I still don't want to break anything and I'm not familiar with other areas that I'd rather not touch for now.

@larzconwell

Ah it's cool man I'm about to push now with all the changes for most of the syntax differences like the if, for, while, function, switch, try/catch, etc statements. I'm going to close this since it only covers the surface, thanks though mate!

@larzconwell

Here's the commit if you're interested (: d9fe3bb

@MiguelMadero

Nice work. Definitely better and more consistent.

@larzconwell

Thanks, and thanks for contributing!

@MiguelMadero

I realized the templates don't use the same conventions. I changed a couple
MiguelMadero@a7e86f0
MiguelMadero@5f7888d

@mde
Owner

Y'all are awesome! Nice work.

@larzconwell larzconwell reopened this
@larzconwell

Oh nice catch @MiguelMadero! Pull down the new changes and I'll merge!

You'll probably get a few merge conflicts(I changed some of the if's to switch statements) with some of those if changes so it would probably be easier to just remove the first commit, or just open a new PR.

EDIT: Oops looks like you did pull the changes in. Just remove the first one including the old if changes and I'll merge it. Just include the generator template changes.

@MiguelMadero

Sorry I missed the edit. I did the two commits (re: formatting in templates) in another branch and they're part of another pull request (#202) because I thought this issue was closed.

@larzconwell

Ah that's okay, I'll just close this one then.

@larzconwell larzconwell closed this
@MiguelMadero

Thanks

@larzconwell

You're welcome, thanks for the PR's love the stuff you're doing!

@MiguelMadero
@mde
Owner
mde commented

This is amazing. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 25, 2012
  1. @MiguelMadero
This page is out of date. Refresh to see the latest.
Showing with 67 additions and 27 deletions.
  1. +21 −11 bin/cli.js
  2. +46 −16 templates/Jakefile
View
32 bin/cli.js
@@ -110,16 +110,22 @@ start = function() {
geddy.start();
};
-if(opts.help) die(usage);
-if(opts.version) die(geddy.version);
+if (opts.help) {
+ die(usage);
+}
+if (opts.version) {
+ die(geddy.version);
+}
// `geddy app foo` or `geddy resource bar` etc. -- run generators
-if(cmds.length) {
+if (cmds.length) {
// Get templates Jake file
filepath = path.normalize(path.join(__dirname, '..', 'templates', 'Jakefile'));
// Wrap quotes in case path has spaces
- if(process.platform === 'win32') filepath = '"' + filepath + '"';
+ if (process.platform === 'win32') {
+ filepath = '"' + filepath + '"';
+ }
cmd = 'jake -t -f ' + filepath + ' ';
// If command isn't secret and has no other argument
@@ -128,18 +134,22 @@ if(cmds.length) {
}
// Add engines to command
- if(opts.jade) {
+ if (opts.jade) {
engineCmd = ',' + 'jade';
- } else if(opts.handle) {
+ } else if (opts.handle) {
engineCmd = ',' + 'handlebars';
- } else if(opts.mustache) {
+ } else if (opts.mustache) {
engineCmd = ',' + 'mustache';
- } else engineCmd = '';
+ } else {
+ engineCmd = '';
+ }
// Get the model properties
- if(cmds.slice(2).length > 0) {
+ if (cmds.slice(2).length > 0) {
modelCmd = ',' + cmds.slice(2).join(' ');
- } else modelCmd = '';
+ } else {
+ modelCmd = '';
+ }
// Add Jake argument based on commands
switch(cmds[0]) {
@@ -184,7 +194,7 @@ if(cmds.length) {
}
exec(cmd, function(err, stdout, stderr) {
- if(err) {
+ if (err) {
throw err;
}
if (stderr) {
View
62 templates/Jakefile
@@ -71,7 +71,9 @@ namespace('db', function () {
if (adapter) {
console.log('Creating table for ' + m);
adapter.createTable(m, function (err, data) {
- if (err) { throw err }
+ if (err) {
+ throw err;
+ }
createTable();
});
}
@@ -149,10 +151,18 @@ namespace('gen', function () {
type = type.replace(/:.*/g, '');
// Defaults and aliases
- if (!type) type = 'string';
- if (type === 'integer') type = 'int';
- if (type === 'bool') type = 'boolean';
- if (args === 'def') args = 'default';
+ if (!type) {
+ type = 'string';
+ }
+ if (type === 'integer') {
+ type = 'int';
+ }
+ if (type === 'bool') {
+ type = 'boolean';
+ }
+ if (args === 'def') {
+ args = 'default';
+ }
if (type === 'default' || type === 'def') {
// If the type is `default` assume they want `string`
// type and want this property to be default
@@ -180,7 +190,7 @@ namespace('gen', function () {
}
// Set property as default if given the `default` argument
- if(args === 'default') {
+ if (args === 'default') {
obj['default'] = {name: name, type: type};
// Add the original ID property
obj['id'] = obj['id'] || {name: 'id', type: 'int'};
@@ -429,7 +439,9 @@ namespace('gen', function () {
});
task('views', function (name, options) {
- if (!name) throw new Error('No view name specified.');
+ if (!name) {
+ throw new Error('No view name specified.');
+ }
options = options || {};
@@ -447,10 +459,18 @@ namespace('gen', function () {
, addActionView;
// Set extension based on engine option
- if (engine === 'ejs') ext += '.ejs';
- if (engine === 'jade') ext += '.jade';
- if (engine === 'handlebars') ext += '.hbs';
- if (engine === 'mustache') ext += '.ms';
+ if (engine === 'ejs') {
+ ext += '.ejs';
+ }
+ if (engine === 'jade') {
+ ext += '.jade';
+ }
+ if (engine === 'handlebars') {
+ ext += '.hbs';
+ }
+ if (engine === 'mustache') {
+ ext += '.ms';
+ }
// Set application layout path
appLayoutPath = path.join('app', 'views', 'layouts', 'application');
@@ -504,10 +524,18 @@ namespace('gen', function () {
, templ;
// Set extension based on engine option
- if (engine === 'ejs') ext += '.ejs';
- if (engine === 'jade') ext += '.jade';
- if (engine === 'handlebars') ext += '.hbs';
- if (engine === 'mustache') ext += '.ms';
+ if (engine === 'ejs') {
+ ext += '.ejs';
+ }
+ if (engine === 'jade') {
+ ext += '.jade';
+ }
+ if (engine === 'handlebars') {
+ ext += '.hbs';
+ }
+ if (engine === 'mustache') {
+ ext += '.ms';
+ }
// Set application layout path
appLayoutPath = path.join('app', 'views', 'layouts', 'application');
@@ -578,7 +606,9 @@ namespace('gen', function () {
text = text.replace(/\nconfig.secret.+\n/, '');
splitText = 'module.exports = config';
- if (environmentPath.match('.js')) splitText += ';';
+ if (environmentPath.match('.js')) {
+ splitText += ';';
+ }
environmentArr = text.split(splitText);
environmentArr[0] += "config.secret = '" + secret + "'";
Something went wrong with that request. Please try again.