@theforeman/find-foreman

For Foreman plugins to find the foreman directory relative to the plugin and return a full path. This can be useful in testing environments where you want to point testing tools at installed Foreman packages rather than duplicate them in the plugin.

Usage no npm install needed!

<script type="module">
  import theforemanFindForeman from 'https://cdn.skypack.dev/@theforeman/find-foreman';
</script>

README

Find Foreman

About

To be used to find Foreman relative to a plugin and return a full path. This is useful in a testing environment when you want to point a testing tool to Foreman's packages rather than duplicate them for testing purposes.

Usage

const {
  foremanLocation,
  foremanRelativePath,
  isForemanLocation
} = require('@theforeman/find-foreman');

const foremanReactRelative = 'webpack/assets/javascripts/react_app';
const foremanFull = foremanLocation();
const foremanReactFull = foremanRelativePath(foremanReactRelative);

isForemanLocation('/home/vagrant/foreman');
// true
isForemanLocation('/home/vagrant/katello');
// false

// When not passing arguments, isForemanLocation would use the process.cwd() to determinate if is foreman location.
isForemanLocation();
// true / false based on current location