Socket
Book a DemoInstallSign in
Socket

inquirer-parse-json-file

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

inquirer-parse-json-file

A selector for Inquirer.js to pick a JSON file and return the Javascript object

latest
Source
npmnpm
Version
1.3.0
Version published
Maintainers
1
Created
Source

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.

Keywords

Inquirer

FAQs

Package last updated on 02 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.