0

I have a frontend-maven-plugin in a super-pom which is used to build the npm artifacts. As part of this step, I decided to build a npm dependency tree and capture the results in a file.

I tried the below step which prints the dependency in StandardOut, is there a way to re-direct this to a file ?

<execution>
 <id>npm tree</id>
 <goals>
   <goal>npm</goal>
 </goals>
 <configuration>
   <arguments>list --prod --json</arguments>
 </configuration>
</execution>

Looked at the npm list, but it doesn't seem to have any file o/p option.

Ganesh D
  • 11
  • 4

1 Answers1

0

I stumbled across the same issue and finally worked out a solution. Just add an entry unter the scripts-Tag in your package.json like this:

 "scripts": {
    "versions-out": "npm list -prod -json > versions.txt ",
    "v2-out": "npm --version > npmv.txt ",
  }

Then in your pom, just call the script with:

                    <execution>
                    <id>library versions</id>
                    <goals>
                        <goal>npm</goal>
                    </goals>
                    <configuration>
                        <arguments>run-script versions-out</arguments>
                    </configuration>
                </execution>

I also ran the v2-out the same way, to ensure that this command uses the npm version specified in the pom rather then my local installation. Yes. it does!

nabinca
  • 2,002
  • 1
  • 18
  • 29