eirslett / frontend-maven-plugin

"Maven-node-grunt-gulp-npm-node-plugin to end all maven-node-grunt-gulp-npm-plugins." A Maven plugin that downloads/installs Node and NPM locally, runs NPM install, Grunt, Gulp and/or Karma.
Apache License 2.0
4.25k stars 871 forks source link

Feature request: execution goal to run node command #525

Open jetownsend opened 7 years ago

jetownsend commented 7 years ago

There should be an easy way to execute a node CLI command (e.g. to run a make script for a dependency) with the installed NodeJS application. We have run executions for npm, Grunt, gulp, webpack, etc. but I don't see one for node, except possibly to use one of the others to exec a node command with a shell.

mdvorak commented 7 years ago

I second that, it could look like

<execution>
    <phase>generate-resources</phase>
    <goals>
        <goal>exec</goal>
    </goals>
    <configuration>
        <executable>ng</executable>
        <arguments>test</arguments>
    </configuration>
</execution>

this will remove need to add specific goals (which will never work in all cases), and everything can be executed thru this.

Current workaround is to add your needed script to package.json, e.g.:

"scripts": {
  "ng": "ng"
}

and then use run command of the npm, with "new" script argument separator --, like this:

<execution>
    <id>test</id>
    <phase>test</phase>
    <goals>
        <goal>npm</goal>
    </goals>
    <configuration>
        <arguments>run ng test -- --single-run</arguments>
    </configuration>
</execution>