1.0.1 • Public • Published


    Travis Coveralls github License: GPL v3 Known Vulnerabilities


    This project searches and reads hierarchically a configuration file in a path provided by params; (e.g. This package can be used to scan and map a set os custom information to feedback and help a CLI code generation tool, making it clever enough to change across mapped directories and do what it takes to its successfuly execution).

    Getting started

    To make use of this package in your project, just npm install like this:

    $ npm i project-info-scanner

    How it works

    The scan process works in two different phases:

    • First, the package get the path provided as first parameter and tries to find a .project-info.json file with a true valued root property (this filename should be provided as second parameter, but the default value is .project-info.json); If the path does not have a configuration file, it'll look upwards until find it. (When the seach process reaches the root path in filesystem, an error is thrown).
    • The second part is the scan process itself. It will start to read the root config file (that it found in First phase) and also reads all children folder seeking for another config files; If the child folder does not contain a config file, the tree search stops there and continue in siblings.

    Usage example

    This package have only one method called "from". The method from has only two parameters:

    • path: required string to be used as initial path of First search phase.
    • configFilename: optional string that reffers to the config filename that will be seeked; The default value is .project-info.json

    from(absolutePath [, configFileName])

    var projectInfoScanner = require('project-info-scanner');
    // If you named your configfile unlike the default value
    projectInfoScanner.from('/any/path/you/want', 'your-custom-name.json');

    See a detailed usage HERE

    The config file structure

    The config file should always be written with JSON syntax. Its default name is .project-info.json, but can be provided another one as second parameter in from method.

    Restricted properties

    There are only two required properties:

    • name: A required string property that must contains the project name (An error is thrown if it's empty or not provided)
    • root: It's only required in the root config file and must contains the value true; If not provided, the package will consider as non root file, even if it was the last existing one in seach process.

    Besides those required properties, we have another couple that are created when the config file is read:

    • dir: A string containing the full path to config file itself.
    • branches: An array containing others config files found in children folder (and it keeps going search whenever a child path contains a config file)

    Obs: If you manually set any of this properties (dir and branches), the package will overwrite them with the correct values.

    Custom properties

    Respecting the JSON syntax, you can add any custom property you want and it will be included in the final output.

    if you want a detailed example, see this GIST

    How to contribute

    Just create a pull request that passes in build process (see travis-ci) and maximum descreases the coverage percentage by 10%.


    npm i project-info-scanner

    DownloadsWeekly Downloads






    Unpacked Size

    66.6 kB

    Total Files


    Last publish


    • byivo