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

Spawn errors ENOENT when using options.base to specify custom Gruntfile.js location #31

Open
ellywebdev opened this issue Oct 22, 2016 · 4 comments

Comments

@ellywebdev
Copy link

Hi there,

As a few have pointed out already, in your documentation it says that setting options.base will be used for specifying a custom Gruntfile.js location. However, in the code it is being used as the path to the grunt executable. This is causing ENOENT errors because it is trying to spawn from an invalid location. (Since the grunt executable would not likely exist in the same directory as the Gruntfile, its either globally installed /usr/bin (etc) and on the PATH, or when grunt-cli is a dependency it would be in node_modules/.bin)

A solution would be to have two separate options for the Gruntfile location and the grunt executable

As a side note, the mocha tests are not picking this error up because it seems that the overriding of process.stdout.write is having the side effect of squelching the failing tests.

@jmcmullen
Copy link

+1

@dmitryshepelev
Copy link

+1, for me too..

@Bradleycorn
Copy link

Don't have a fix for this, but I do have a workaround. There is a grunt plugin called grunt-hub, whose purpose is to load and run tasks in grunt files that are in child folders/projects. I was able to leverage this plugin to get around this error.

first, setup gulp-grunt in your gulpfile with no "base" option (you can specify other options if you want) ...

require('gulp-grunt')(gulp); 

This will look for a gruntfile in the same folder with your gulpfile. So, we create a gruntfile there that uses grunt-hub, and configure it to look for the child gruntfile that you need to run, and register tasks to run specific hub targets.

module.exports = function(grunt) {
    grunt.loadNpmTasks('grunt-hub');

    grunt.initConfig({
        hub: {
            testCode: {
                src: ['path/to/child/Gruntfile.js'],
                tasks: ['jshint', 'nodeunit']
            },
            build: {
                src: ['path/to/child/Gruntfile.js'],
                tasks: ['sass','minify','uglifyjs']
            }
        }
    });

   grunt.registerTask('test',['hub:testCode']);
   grunt.registerTask('build',['hub:build']);
   grunt.registerTask('all',['hub:testCode','hub:build']);
}

Finally, back in your gulp file, use gulp-grunt like normal to use the tasks you created in your new gruntfile (which will in turn use hub to run the grunt tasks in the file further down in the directory tree).

gulp.registerTask('do-grunt-things', ['grunt-test']);
gulp.registerTask('combine', ['some-gulp-task', 'grunt-build', 'some-other-gulp-task']);

It's not optimal, but it works. Hope this helps. It worked for me.

@wesleypimentel
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants