inquirer-parse-json-file

1.3.0 • Public • Published

inquirer-parse-json-file

Json File prompt for inquirer

Parses the JSON file and returns the object as it's answer.

Installation

npm install --save inquirer-parse-json-file

Features

  • Support for symlinked files
  • Vim style navigation
  • Support for parsing JSON files with comments now!

Key Maps

  • Use either up/down arrow keys or k/j to navigate
  • Use enter to select option

Usage

This prompt is anonymous, meaning you can register this prompt with the type name you please:

inquirer.registerPrompt('jsonFile', require('inquirer-parse-json-file'));
inquirer.prompt({
  type: 'jsonFile',
  ...
})

Change jsonFile to whatever you might prefer.

Options

Takes type, name, message, filter, basePath properties.

See inquirer readme for meaning of all except basePath.

basePath is the relative path from your current working directory

Example

inquirer.registerPrompt("jsonFile", require("inquirer-parse-json-file"));
inquirer
  .prompt([
    {
      type: "jsonFile",
      name: "json",
      message: "Select a json file?",
      basePath: "./src",
    },
  ])
  .then(function (answers) {
    // (answers.from is the path chosen)
  });

See also example.js for a working example

Contributing

Unit test Unit test are written in Mocha. Please add a unit test for every new feature or bug fix. npm test to run the test suite.

Documentation Add documentation for every API change. Feel free to send typo fixes and better docs!

License

MIT

Acknowledgements

Thanks to bmbarker90 and their inquirer-file-path repo that this is adapted from.

Future features

  • none. Have an Idea? Submit a Feature Request.

/inquirer-parse-json-file/

    Package Sidebar

    Install

    npm i inquirer-parse-json-file

    Weekly Downloads

    4

    Version

    1.3.0

    License

    MIT

    Unpacked Size

    107 kB

    Total Files

    11

    Last publish

    Collaborators

    • mdoll