linemanjs / lineman

Lineman helps you build fat-client JavaScript apps. It produces happiness by building assets, mocking servers, running specs on every file change
MIT License
1.18k stars 83 forks source link

lineman run fails after using grunt-exec #376

Closed ghost closed 8 years ago

ghost commented 8 years ago

DESCRIPTION

As it will be shown below, all is well until a task that uses grunt-exec is executed; the same happened with shelljs. Once a command shell is used to issue an external command, lineman gets into a strange state preventing it form performing its basic work.

STEPS TO REPRODUCE

module.exports = function(lineman) {
        ... removed for brevity
        fetcher: {
            recipeRepo: "https://github.com/Dematiclabs/fetcher-recipes"
        }
    };
};
module.exports = function(grunt) {
   grunt.initConfig({
      exec: {
         'angular': 'lineman fetch "angular"',
         'angular-bootstrap': 'lineman fetch "angular-bootstrap"'
      }
   });
   grunt.loadNpmTasks('grunt-exec');
   grunt.registerTask('dl-fetch', ['exec']);
};
$ lineman run
Running "common" task

Running "ngtemplates:app" (ngtemplates) task
File generated/angular/template-cache.js created.

... omitted for brevity

Running "watch" task
Waiting...
$ lineman grunt dl-fetch
Running "exec:angular" (exec) task
Fetching recipes from 'https://github.com/Dematiclabs/fetcher-recipes'...
Downloading 'http://code.angularjs.org/1.4.5/angular.js'...

... omitted for brevity
Successfully installed 'angular-bootstrap'.

OBSERVED BEHAVIOR

$ lineman run
Running "common" task

>> No "ngtemplates" targets found.
Warning: Task "ngtemplates" failed. Used --force, continuing.

... omitted for brevity

Running "watch" task
Verifying property watch exists in config...ERROR
>> Unable to process task.
Warning: Required config property "watch" missing. Used --force, continuing.

Done, but with warnings.

EXPECTED BEHAVIOR

The lineman run, and all other lineman functionality, should work after running lineman grunt dl-fetch

ghost commented 8 years ago

SOLUTION

After debugging the problem, I learned that the undesired symptoms are only when the dl-fetcher.js file is present! The root-cause, it is the following code snippet in dl-fetcher.js:

   grunt.initConfig({
        exec: {
            'angular': 'lineman fetch "angular"',
            'angular-bootstrap': 'lineman fetch "angular-bootstrap"'
        }
    });

It totally resets the whole lineman configuration! OUCH! The solution was to declare the exec object in applications.js:

       . . . 
        exec: {
            'angular': 'lineman fetch "angular"',
            'angular-bootstrap': 'lineman fetch "angular-bootstrap"',
            'underscore': 'lineman fetch "underscore"'
        },
        . . . 

This was an excellent exercise, I know fully understand how to write grunt tasks for lineman!

Sorry for taking up space here. On the other hand, writing this helped me figure out the solution. I also hope that folks who read it might learn from it.

searls commented 8 years ago

Hey we don't mind you working in the open. It might help someone else in the future. Glad it worked out. On Sat, Sep 12, 2015 at 16:56 Rodrigo Silveira notifications@github.com wrote:

Closed #376 https://github.com/linemanjs/lineman/issues/376.

— Reply to this email directly or view it on GitHub https://github.com/linemanjs/lineman/issues/376#event-407919450.