Skip to content

Commit

Permalink
MDL-50001 grunt: Make grunt work on windows
Browse files Browse the repository at this point in the history
Unfortunately, this is not perfect yet. It will build the entire
repository every time - which takes a while because it builds all the
yui modules (On linux it correctly only builds whats in the current dir).
  • Loading branch information
Damyon Wiese committed May 5, 2015
1 parent 119ff65 commit e67585f
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

module.exports = function(grunt) {
var path = require('path'),
tasks = {};
tasks = {},
cwd = process.env.PWD || process.cwd();

// Project configuration.
grunt.initConfig({
Expand All @@ -38,11 +39,11 @@ module.exports = function(grunt) {
['**/src/*.js', '!**/node_modules/**'],
'',
{
cwd: process.env.PWD,
cwd: cwd,
rename: function(destBase, destPath) {
destPath = destPath.replace('src', 'build');
destPath = destPath.replace('.js', '.min.js');
destPath = path.resolve(process.env.PWD, destPath);
destPath = path.resolve(cwd, destPath);
return destPath;
}
}
Expand All @@ -63,13 +64,15 @@ module.exports = function(grunt) {
},
shifter;

args.push( path.normalize(__dirname + '/node_modules/shifter/bin/shifter'));

// Determine the most appropriate options to run with based upon the current location.
if (path.basename(process.env.PWD) === 'src') {
if (path.basename(cwd) === 'src') {
// Detect whether we're in a src directory.
grunt.log.debug('In a src directory');
args.push('--walk');
options.walk = true;
} else if (path.basename(path.dirname(process.env.PWD)) === 'src') {
} else if (path.basename(path.dirname(cwd)) === 'src') {
// Detect whether we're in a module directory.
grunt.log.debug('In a module directory');
options.module = true;
Expand Down Expand Up @@ -100,8 +103,8 @@ module.exports = function(grunt) {
}

// Actually run shifter.
shifter = exec(process.cwd() + '/node_modules/shifter/bin/shifter', args, {
cwd: process.env.PWD,
shifter = exec("node", args, {
cwd: cwd,
stdio: 'inherit',
env: process.env
});
Expand All @@ -119,10 +122,10 @@ module.exports = function(grunt) {

tasks.startup = function() {
// Are we in a YUI directory?
if (path.basename(path.resolve(process.env.PWD, '../../')) == 'yui') {
if (path.basename(path.resolve(cwd, '../../')) == 'yui') {
grunt.task.run('shifter');
// Are we in an AMD directory?
} else if (path.basename(process.env.PWD) == 'amd') {
} else if (path.basename(cwd) == 'amd') {
grunt.task.run('jshint');
grunt.task.run('uglify');
} else {
Expand Down

0 comments on commit e67585f

Please sign in to comment.