diff --git a/README.md b/README.md
index b0eb33b28..e83f52faf 100644
--- a/README.md
+++ b/README.md
@@ -65,6 +65,7 @@ to see how it should be set up: https://github.com/eirslett/frontend-maven-plugi
- [jspm](#running-jspm)
- [karma](#running-karma)
- [webpack](#running-webpack)
+ - [node](#running-node)
- Configuration
- [Working Directory](#working-directory)
- [Installation Directory](#installation-directory)
@@ -399,6 +400,25 @@ will help to separate your frontend and backend builds even more.
```
+### Running node
+You may need to run `node` with arbitrary arguments. Check this Mojo :
+```xml
+
+ compile-xsl
+
+ node
+
+
+
+ compile
+
+
+
+ node_modules/xslt3/xslt3.js -xsl:src/main/xsl/md-to-xml.xsl -export:target/webapp/md-to-xml.sef.json
+
+
+```
+
### Optional Configuration
#### Working directory
@@ -529,6 +549,7 @@ Tools and property to enable skipping
* jspm `-Dskip.jspm`
* karma `-Dskip.karma`
* webpack `-Dskip.webpack`
+* node `-Dskip.node`
## Eclipse M2E support
diff --git a/frontend-maven-plugin/src/main/java/com/github/eirslett/maven/plugins/frontend/mojo/NodeMojo.java b/frontend-maven-plugin/src/main/java/com/github/eirslett/maven/plugins/frontend/mojo/NodeMojo.java
new file mode 100644
index 000000000..754734f36
--- /dev/null
+++ b/frontend-maven-plugin/src/main/java/com/github/eirslett/maven/plugins/frontend/mojo/NodeMojo.java
@@ -0,0 +1,37 @@
+package com.github.eirslett.maven.plugins.frontend.mojo;
+
+import com.github.eirslett.maven.plugins.frontend.lib.FrontendException;
+import com.github.eirslett.maven.plugins.frontend.lib.FrontendPluginFactory;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+
+@Mojo(name="node", defaultPhase = LifecyclePhase.COMPILE, threadSafe = true)
+public class NodeMojo extends AbstractFrontendMojo {
+ /**
+ * npm arguments. Default is "install".
+ */
+ @Parameter(defaultValue = "", property = "frontend.node.arguments", required = false)
+ private String arguments;
+
+ @Parameter(property = "session", defaultValue = "${session}", readonly = true)
+ private MavenSession session;
+
+ /**
+ * Skips execution of this mojo.
+ */
+ @Parameter(property = "skip.node", defaultValue = "${skip.node}")
+ private boolean skip;
+
+ @Override
+ protected void execute(FrontendPluginFactory factory) throws FrontendException {
+ getLog().info("Running NodeMojo");
+ factory.getNodeRunner().execute(arguments, environmentVariables);
+ }
+
+ @Override
+ protected boolean skipExecution() {
+ return skip;
+ }
+}
diff --git a/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/FrontendPluginFactory.java b/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/FrontendPluginFactory.java
index 4ed8b1a6b..f2aa862a4 100644
--- a/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/FrontendPluginFactory.java
+++ b/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/FrontendPluginFactory.java
@@ -92,4 +92,8 @@ private InstallConfig getInstallConfig() {
private static final CacheResolver getDefaultCacheResolver(File root) {
return new DirectoryCacheResolver(new File(root, DEFAULT_CACHE_PATH));
}
+
+ public NodeRunner getNodeRunner() {
+ return new NodeRunner(getExecutorConfig());
+ }
}
diff --git a/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/NodeRunner.java b/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/NodeRunner.java
new file mode 100644
index 000000000..095064178
--- /dev/null
+++ b/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/NodeRunner.java
@@ -0,0 +1,32 @@
+package com.github.eirslett.maven.plugins.frontend.lib;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.Map;
+
+public class NodeRunner {
+ private final NodeExecutorConfig config;
+ private final ArgumentsParser argumentsParser;
+ private final Logger logger = LoggerFactory.getLogger(NodeRunner.class);
+
+ public NodeRunner(NodeExecutorConfig config) {
+ super();
+ this.config = config;
+ argumentsParser = new ArgumentsParser();
+ }
+
+ public void execute(String arguments, Map environmentVariables) throws FrontendException {
+ NodeExecutor nodeExecutor = new NodeExecutor(config, getArguments(arguments), environmentVariables);
+ try {
+ nodeExecutor.executeAndRedirectOutput(logger);
+ } catch (ProcessExecutionException e) {
+ throw new FrontendException("executing node "+arguments, e);
+ }
+ }
+
+ private List getArguments(String arguments) {
+ return argumentsParser.parse(arguments);
+ }
+}
\ No newline at end of file