Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated to account for npm3 installing local modules to a flat direct… #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
24 changes: 21 additions & 3 deletions bsp-grunt.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {

Expand Down Expand Up @@ -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
}
}
},
Expand Down Expand Up @@ -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');

Expand All @@ -216,4 +234,4 @@ module.exports = function(grunt, config) {
'bsp'
]);

};
};