Socket
Book a DemoInstallSign in
Socket

config-comments

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

config-comments

Parse argument commands/options from code comments using esprima and minimist.

Source
npmnpm
Version
0.3.1
Version published
Weekly downloads
5
150%
Maintainers
1
Weekly downloads
 
Created
Source

config-comments NPM version

Build Status

Parse argument commands/options from code comments using esprima and minimist.

  • Usage
  • API
  • License

(TOC generated by verb using markdown-toc)

Usage

var configComments = require('config-comments');

configComments('my-app', string[, options]);

Example

Assuming we have the following in file lib.js:

// my-app: foo bar baz */
function foo(str) {
  return str;
}

function bar(str) {
  /* my-app: --disable=qux */
  return str;
}

We would pass lib.js as a string to configComments:

var config = configComments('my-app', str);

Result

{ 
  abc: { 
  _: [ 'foo', 'bar', 'baz' ], 
    disable: 'qux' 
  } 
}

API

configComments(keywords, string[, options]);

Pass one or more keywords to be used for matching comments that have arguments to be parsed by minimist.

Params

  • keywords {String|Array}: Keyword(s) to identify comments to parse.
  • str {String}: A string of valid javascript with comments to parse.
  • options {Object}: Options to pass to minimist
  • returns {Object}: Object of parsed arguments.

Requirements

In configComments comments:

  • A keyword must be the first thing in the comment. Leading whitespace is allowed.
  • A comment should only have arguments that can be parsed by minimist

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Author

Jon Schlinkert

License

Copyright © 2016 Jon Schlinkert Released under the MIT license.

This file was generated by verb on January 08, 2016.

Keywords

args

FAQs

Package last updated on 10 Jan 2016

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