Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixes for issues 1196 and 1197 #199

Merged
merged 5 commits into from

3 participants

@MiguelMadero

No description provided.

templates/Jakefile
@@ -113,7 +114,10 @@ namespace('gen', function () {
templ.process({names: names, bare: bare, properties: options.properties});
// Write file
- filePath = path.join('app', dirname, names.filename[options.inflection] + '.js');
+ fileDir = path.join('app', dirname);
+ if (!fs.existsSync(fileDir)) fs.mkdirSync(fileDir);

fs.existsSync isn't available on Node 0.6, so use utils.file.existsSync it provides compatibility for 0.6 and 0.8.

Also could you include the brackets on the statement? and ensure the statement is on it's own line. That way changes later can be seen easier.
Note: Please update the changed if statement in bin/cli.js also.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@larzconwell

Awesome! Just make the changes mentioned in the code discussion and I'll merge.

@MiguelMadero

I pushed the requested changed.

Thanks for the feedback. I'm new to Node and I wasn't thinking about the compatibility issues. Did you just knew this from memory or is there an easy way to test for compatibility?

@larzconwell

Well after a while you just get used to the differences, mostly from using 0.6. But you can check here for the list of changes between the two. We only support the two latest stable releases so all the 0.6.* and 0.8.* versions, stable Node releases are even, while unstable are odd.

Oh, can you change the first if statement also? It's still inline.

@MiguelMadero

I noticed there're plenty of inlined if's. What's the difference or is it just old code that hasn't been changed?
In cli.js

    if(opts.help) die(usage);

In Jakefile

    if (!type) type = 'string';
    if (type === 'integer') type = 'int';
    // a few more...
@larzconwell

Yeah it's pretty much old code or code I've accidentally put in like that (;

Should probably fix all those when I push next time. I'll go ahead and merge this then I'll fix that if later.

@larzconwell larzconwell merged commit 8484f10 into geddy:master
@mde
Owner

Nice!

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
  2. @MiguelMadero

    Changed the generator to create the directory in case it doesn't exis…

    MiguelMadero authored
    …t. GIT won't add empty folders (eg models) and the generator wasn't creating them
  3. @MiguelMadero

    Removed usage of fs.existsSync for compatibility with node 0.6 and ch…

    MiguelMadero authored
    …anged formatting as requested
  4. @MiguelMadero
  5. @MiguelMadero

    Changed formatting

    MiguelMadero authored
This page is out of date. Refresh to see the latest.
Showing with 11 additions and 2 deletions.
  1. +4 −1 bin/cli.js
  2. +7 −1 templates/Jakefile
View
5 bin/cli.js
@@ -179,7 +179,10 @@ if(cmds.length) {
die(cmds[0] + ' is not a Geddy command.');
}
- //cmd += ' --quiet';
+ if (!opts.debug) {
+ cmd += ' --quiet';
+ }
+
exec(cmd, function(err, stdout, stderr) {
if(err) {
throw err;
View
8 templates/Jakefile
@@ -106,6 +106,7 @@ namespace('gen', function () {
, text = fs.readFileSync(path.join(__dirname, filename + '.ejs'), 'utf8').toString()
, bare = options.bare || false // Default to full controller
, templ
+ , fileDir
, filePath;
// Render with the right model name
@@ -113,7 +114,12 @@ namespace('gen', function () {
templ.process({names: names, bare: bare, properties: options.properties});
// Write file
- filePath = path.join('app', dirname, names.filename[options.inflection] + '.js');
+ fileDir = path.join('app', dirname);
+ if (!utils.file.existsSync(fileDir)) {
+ fs.mkdirSync(fileDir);
+ }
+
+ filePath = path.join(fileDir, names.filename[options.inflection] + '.js');
fs.writeFileSync(filePath, templ.markup, 'utf8');
console.log('[Added] ' + filePath);
Something went wrong with that request. Please try again.