Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Fixes bug in base_path resolution #20

Open
wants to merge 2 commits into
from

Conversation

Projects
None yet
2 participants

Due to how paths are shipped around,
base_path would not correctly handle files in the root path, nesting them.

For instance, a base_path of 'app/js' has been passed,
which becomes 'app/js/' in the task.

Notice in the output that all files are properly re-based,
except for those directly inside 'app/js/' (namely main.js, app.js):

Running "coffee:app" (coffee) task
Verifying property coffee.app exists in config...OK
>> Note that grunt.utils has been renamed to grunt.util and is now deprecated.
>> Please ensure that your custom tasks are up-to-date. (grunt 0.4.0+)
Reading app/js/app.coffee...OK
Writing generated\js\app\js\app.js...OK
Reading app/js/controllers/auth.coffee...OK
Writing generated\js\controllers\auth.js...OK
Reading app/js/directives/directives.coffee...OK
Writing generated\js\directives\directives.js...OK
Reading app/js/filters/filters.coffee...OK
Writing generated\js\filters\filters.js...OK
Reading app/js/main.coffee...OK
Writing generated\js\app\js\main.js...OK
Reading app/js/services/auth.coffee...OK
Writing generated\js\services\auth.js...OK

With this fixed, we get the following desired output

Running "coffee:app" (coffee) task
Verifying property coffee.app exists in config...OK
>> Note that grunt.utils has been renamed to grunt.util and is now deprecated.
>> Please ensure that your custom tasks are up-to-date. (grunt 0.4.0+)
Reading app/js/app.coffee...OK
Writing generated\js\app.js...OK
Reading app/js/controllers/auth.coffee...OK
Writing generated\js\controllers\auth.js...OK
Reading app/js/directives/directives.coffee...OK
Writing generated\js\directives\directives.js...OK
Reading app/js/filters/filters.coffee...OK
Writing generated\js\filters\filters.js...OK
Reading app/js/main.coffee...OK
Writing generated\js\main.js...OK
Reading app/js/services/auth.coffee...OK
Writing generated\js\services\auth.js...OK
@Iristyle Iristyle Fixes bug in base_path resolution
Due to how paths are shipped around,
base_path would not correctly handle files in the root path, nesting them.

For instance, a base_path of 'app/js' has been passed, 
which becomes 'app/js/' in the task.

Notice in the output that all files are properly re-based,
except for those directly inside 'app/js/' (namely main.js, app.js):

Running "coffee:app" (coffee) task
Verifying property coffee.app exists in config...OK
>> Note that grunt.utils has been renamed to grunt.util and is now deprecated.
>> Please ensure that your custom tasks are up-to-date. (grunt 0.4.0+)
Reading app/js/app.coffee...OK
Writing generated\js\app\js\app.js...OK
Reading app/js/controllers/auth.coffee...OK
Writing generated\js\controllers\auth.js...OK
Reading app/js/directives/directives.coffee...OK
Writing generated\js\directives\directives.js...OK
Reading app/js/filters/filters.coffee...OK
Writing generated\js\filters\filters.js...OK
Reading app/js/main.coffee...OK
Writing generated\js\app\js\main.js...OK
Reading app/js/services/auth.coffee...OK
Writing generated\js\services\auth.js...OK
9b6655c
Owner

avalade commented Sep 11, 2012

Looks good, except you should use path.sep instead of using the hard-coded / character. If you want to update your commit with that, then I will merge it.

You're right.. totally slipped my mind. Will update in a few.

Note however that I'm on Windows... and my path chars are '/' ;0

Ok, so path.sep wouldn't work all of the time, because there is nothing to ensure that base_path has a style that matches the OS.

Even though I'm on Windows, I tend to use / in config files because in my experience, it just works.

So the solution also includes a bit of normalization.. and some tweaks to make sure the resultant RegEx is safe to use - but apparently Travis doesn't like it! Looking into it...

Not sure what's causing the fails in the tests here... only failing on 0.6

Any ideas?

Owner

avalade commented Sep 25, 2012

Looks like path.sep was only introduced in the NodeJS 0.7 development cycle so it's not available in Node 0.6. I've removed the call to path.sep and instead just rely on path.join to "do the right thing" in this commit 0e10ca5. If that looks good to you, I'll merge it in.

Iristyle commented Oct 5, 2012

Sorry it took so long to get back with you here.... unfortunately that doesn't work either.

However, I do have a fix -- pretty similar to this one.
arian/wrapup@74fd505

Updating pull in just a sec.

@Iristyle Iristyle Fixes bug in base_path resolution
Due to how paths are shipped around, base_path would not correctly
handle files in the root path, nesting them.

Properly normalizes paths / uses path.sep when available, so that
this will work on all operating systems, regardless of how paths
are configured in the configuration file.

For instance, a base_path of 'app/js' has been passed,
which becomes 'app/js/' in the task.

Notice in the output that all files are properly re-based,
except for those directly inside 'app/js/' (namely main.js, app.js):

Running "coffee:app" (coffee) task
Verifying property coffee.app exists in config...OK
>> Note that grunt.utils has been renamed to grunt.util and is now deprecated.
>> Please ensure that your custom tasks are up-to-date. (grunt 0.4.0+)
Reading app/js/app.coffee...OK
Writing generated\js\app\js\app.js...OK
Reading app/js/controllers/auth.coffee...OK
Writing generated\js\controllers\auth.js...OK
Reading app/js/directives/directives.coffee...OK
Writing generated\js\directives\directives.js...OK
Reading app/js/filters/filters.coffee...OK
Writing generated\js\filters\filters.js...OK
Reading app/js/main.coffee...OK
Writing generated\js\app\js\main.js...OK
Reading app/js/services/auth.coffee...OK
Writing generated\js\services\auth.js...OK
3913a7b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment