com.github.sdorra.buildfrontend.NpmPackageManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of buildfrontend-maven-plugin Show documentation
Show all versions of buildfrontend-maven-plugin Show documentation
Installs and run node, npm or yarn as part of your maven build
package com.github.sdorra.buildfrontend;
import com.google.common.collect.Lists;
import java.util.Collections;
import java.util.List;
public class NpmPackageManager implements PackageManager {
private final Node node;
private final String executable;
NpmPackageManager(Node node, String executable) {
this.node = node;
this.executable = executable;
}
@Override
public void install() {
npm("install");
}
@Override
public void run(String script) {
npm("run", script);
}
@Override
public void link() {
npm( "link");
}
@Override
public void link(String pkg) {
npm("link", pkg);
}
private void npm(String... args) {
List lists = Lists.newArrayList("--color=false", "--parseable");
Collections.addAll(lists, args);
node.execute(executable, lists.toArray(new String[0]));
}
}