How to retrieve collection path in custom reporter for newman

Hello everyone,
I’ m writing a custom junit reporter for newman that should display the name of the collection as it is saved on the filesystem. I haven’t found a way yet, do you know if it is feasible? For now I’m only able to retrieve the name of the collection as it is specified inside the .json
For example:
I have one collection saved in the filesystem as collection1.json, i would like to retrieve not only the working directory, which I already have from the javascript, but also “collection1”.
Thanks in advance :slight_smile:

Hi, @giomem33,

You can actually re-parse the arguments coming into the command line. You need to use the commander module.


    const { program } = require('commander');

    let collectionSpecified;
      .command('run <collection>')
      .action((collection) => {
        collectionSpecified = collection;

    console.log('collection:', collectionSpecified);

EDIT: Note that the collection specifier might be a file path or a URL.

Hope this helps.