Skip to content

Commit

Permalink
Merge pull request #32 from mrjoelkemp/fix_sass
Browse files Browse the repository at this point in the history
Handle the case when we have both requirejs and browserify configs. Fixe...
  • Loading branch information
mrjoelkemp committed Jun 4, 2014
2 parents 395d747 + 2466fb8 commit d0d772b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
13 changes: 11 additions & 2 deletions helpers/GruntHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,19 @@ module.exports.prototype.getCompileConfig = function (targets) {

// Attaches the watch configuration to the passed grunt configuration
module.exports.prototype.getWatchConfig = function (gruntConfig, extensions) {
var watchConfig = {};
var watchConfig = {},
targets = Object.keys(gruntConfig),
// If we have both types, then the number of configuration
// targets exceeds the number of extensions, so we need to remedy that
hasBothJSModuleTypes = targets.indexOf('browserify') !== -1 &&
targets.indexOf('requirejs') !== -1;

if (hasBothJSModuleTypes) {
extensions.splice(extensions.indexOf('.js') + 1, 0, '.js');
}

// Watch the files for handled extensions
Object.keys(gruntConfig).forEach(function (target, idx) {
targets.forEach(function (target, idx) {
var currentExt = extensions[idx];

// TODO: This should likely be a per-extension setting config
Expand Down
3 changes: 0 additions & 3 deletions helpers/JsHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,8 @@ JSH.prototype.getSettings = function () {
var that = this;

return this.getRoots().then(function (roots) {
console.log('JSH: Fetched roots')
return q.all(roots.map(that.getModuleType.bind(that)))
.then(function (moduleTypes) {
console.log('JSH: Fetched module types')

return that.generateSettings(roots, moduleTypes);
});
});
Expand Down
6 changes: 0 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ function onJSChanged() {
// a root file changes: index.js could remove require of lib/index making index.js a root and lib/index a root
// a non-root file changes: b.js is the root and a.js changes to require b.js making it the new root
return this.jsh.getRoots().then(function (roots) {
// console.log('Pulled roots', roots, '\nold roots: ', that.jsh._oldRoots)
return that.jsh.haveRootsChanged(roots);
})
.then(function (haveRootsChanged) {
Expand All @@ -312,18 +311,13 @@ function onJSChanged() {

// Need all of the targets to regenerate the gruntfile
return that.getAllSettings().then(function (targets) {
// console.log('Getting config')
return that.engine.getConfig(targets, that.extensions);
})
.then(function (config) {
// Grab the targets for the apps and merge with the existing targets
return that.jsh.getSettings().then(function (settings) {
// console.log('JS Settings: ', settings)
// console.log('JS Settings Target: ', settings.target)

utils.shallowExtend(config, settings.target);

// console.log('Extended Config: ', config)
return config;
});
})
Expand Down

0 comments on commit d0d772b

Please sign in to comment.