diff --git a/bsp-grunt.js b/bsp-grunt.js index bd3a072..a4a7b01 100644 --- a/bsp-grunt.js +++ b/bsp-grunt.js @@ -6,6 +6,21 @@ module.exports = function(grunt, config) { var Builder = require('systemjs-builder'); var builder = new Builder(); + // npm 3 flattens the node_modules directory structure, so + // we need to look for modules at multiple paths + var lessContribDir; + grunt.file.recurse( + process.cwd() + '/node_modules', + function(abspath, rootdir, subdir, filename) { + if (/\/less$/.test(subdir) && !lessContribDir) { + var subDirFullPath = process.cwd() + '/node_modules/' + subdir; + if (grunt.file.exists(subDirFullPath + '/bower.json')) { + lessContribDir = subDirFullPath; + } + } + } + ); + grunt.initConfig(EXTEND(true, { }, { bsp: { @@ -99,8 +114,8 @@ module.exports = function(grunt, config) { less: { files: { '<%= bsp.scripts.devDir %>/less.js': - __dirname + '/node_modules/grunt-contrib-less/node_modules/less/' + - grunt.file.readJSON(__dirname + '/node_modules/grunt-contrib-less/node_modules/less/bower.json').main + lessContribDir + + grunt.file.readJSON(lessContribDir + '/bower.json').main } } }, @@ -191,7 +206,10 @@ module.exports = function(grunt, config) { }, (config || { }))); + // look in two places because npm3 downloads modules to + // a flat directory structure grunt.file.expand(__dirname + '/node_modules/grunt-*/tasks').forEach(grunt.loadTasks); + grunt.file.expand(process.cwd() + '/node_modules/grunt-*/tasks').forEach(grunt.loadTasks); grunt.loadTasks(__dirname + '/tasks'); @@ -216,4 +234,4 @@ module.exports = function(grunt, config) { 'bsp' ]); -}; +}; \ No newline at end of file