npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-maven-api

v2.0.2

Published

Run maven commands via a node js api!

Downloads

86

Readme

node-maven-api

Build Status Dependency Status Codacy Badge Code Climate Issue Count Test Coverage Downloads

Run maven commands via a Node JS API!

Usage

To create the maven handler, you need to call the create method providing the path to the POM file to be handled.

var mvn = require('node-maven-api').create('/workspace/project/pom.xml');

mvn.clean();
mvn.install();

Clean

Invoke a maven clean on your project.

mvn.clean();

Install

Invoke a maven install on your project.

mvn.install();

Test

Invoke a maven test on your project.

mvn.test();

Effective POM

Get the effective pom for your project. A promise will be returned which will be resolved to a javascript object which represents the xml effective pom.

var promise = mvn.effectivePom();

promise.then((result) => {
    console.log('Effective POM is: ', result);
});

Custom Commands

The API provided by this module can not possibly cover every maven goal, there is far too many! You can run any command you need with the execCommand function.

Function Parameters:

  1. The event name for your command.
  2. The command to execute.
// mvn clean install -f /path/to/my/pom.xml
mvn.execCommand('my-custom-event', 'clean install');

Events

Sometimes you might want to perform some action after you have executed a maven command. Upon completion of a process, the api will trigger an event via the Node JS EventEmitter.

For the methods which this api exposes, the event names are as you may expect:

  • clean
  • clean-failed
  • install
  • install-failed
  • test
  • test-failed
  • effective-pom
  • effective-pom-failed

For custom commands you may provide your own event name, with the assumption that '-failed' will be automatically added in the event of a failure.

You may use the registerEvent function to bind a callback to an event.

Function Parameters:

  1. The event name to bind a callback to.
  2. The callback to bind to the event.

Example:

mvn.registerEvent('my-custom-event', () => {
  console.log('My Custom Maven command was successful! :)')
});

mvn.registerEvent('my-custom-event-failed', () => {
  console.error('My Custom Maven command Failed... :(')
});

mvn.execCommand('my-custom-event', 'clean install');