How to run a script in node_modules from a grunt task?

I want to simplify the use of our test suites from the command line. Therefore, I added the following grunt-shell task to ours Gruntfile.js:

module.exports = function( grunt ) {

  grunt.initConfig(
    {
      shell : {
        e2e : {
          command : "./node_modules/protractor/bin/protractor protractor_conf.js"
        }
      }
    }
  );

  grunt.loadNpmTasks( "grunt-shell" );

  grunt.registerTask( "e2e", ["shell:e2e"] );
};

When I run the task, I get an error message:

'.' is not recognized as an internal or external command, operable program or batch file.

All the examples that I found to run shell commands ran binaries that were available around the world, but I want to run the protractor binary that was installed locally.

I use bash for Windows if that matters.

+4
source share
2 answers

You can pass protractoras an argument nodeto call it, for example:

module.exports = function( grunt ) {

  grunt.initConfig(
    {
      shell : {
        e2e : {
          command : "node ./node_modules/protractor/bin/protractor protractor_conf.js"
        }
      }
    }
  );

  grunt.loadNpmTasks( "grunt-shell" );

  grunt.registerTask( "e2e", ["shell:e2e"] );
};
0
source

OSX... ?

Grunt:

module.exports = function(grunt) {

    grunt.initConfig({
        shell: {
            test: {
                // command: 'sh /Users/default/Sites/dev/test.sh'
                command: 'node /Users/default/Sites/dev/test.js'
            }
        }
    });

    grunt.loadNpmTasks('grunt-shell');
    grunt.registerTask('default', ['shell']);
};

.

, :

grunt-execute, grunt-run

+1

Source: https://habr.com/ru/post/1540930/


All Articles