Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions tasks/coffee.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

module.exports = function(grunt) {
var path = require('path');
var isWindows = process.platform === "win32";
var pathsep = path.sep || isWindows ? '\\' : '/';

// Please see the grunt documentation for more information regarding task and
// helper creation: https://github.com/cowboy/grunt/blob/master/docs/toc.md
Expand Down Expand Up @@ -44,9 +46,11 @@ module.exports = function(grunt) {
extension = typeof extension === "undefined" ? '.js' : extension;

if( destPath && options.preserve_dirs ){
var dirname = path.dirname(src);
var dirname = path.normalize(path.dirname(src)) + pathsep;
if ( options.base_path ) {
dirname = dirname.replace(new RegExp('^'+options.base_path), '');
//on Windows, path.sep must be escaped in a regex
var safeRegex = path.normalize(options.base_path).replace(/\\/g, "\\\\");
dirname = dirname.replace(new RegExp('^' + safeRegex), '');
}
destPath = path.join(destPath, dirname);
} else if( !destPath ){
Expand Down