Socket
Socket
Sign inDemoInstall

remark-license

Package Overview
Dependencies
5
Maintainers
14
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    remark-license

Add a license section to your README


Version published
Weekly downloads
348
decreased by-22.67%
Maintainers
14
Install size
6.81 MB
Created
Weekly downloads
 

Readme

Source

remark-license

Build Coverage Downloads Chat Sponsors Backers

Add a license section to a README with remark.

Installation

npm:

npm install remark-license

Usage

Say we have the following file, example.md:

## License

Something nondescript.

And our script, example.js, looks as follows:

var fs = require('fs')
var remark = require('remark')
var license = require('remark-license')

remark()
  .use(license)
  .process(fs.readFileSync('example.md'), function(err, file) {
    if (err) throw err
    console.log(String(file))
  })

Now, running node example yields:

## License

[MIT](LICENSE) © [Titus Wormer](https://wooorm.com)

API

remark.use(license[, options])

Add a license section to heading containing /^licen[cs]e$/i. Replaces the original content of the section. Does nothing when no heading is found. Does nothing when the processed file is the license file (such for a license heading in license.md).

options
options.name

string, optional — License holder. Detected from the package.json in the current working directory, supporting both object and string format of author. Throws when neither given nor detected.

options.license

string, optional — SPDX identifier. Detected from the license field in the package.json in the current working directory. Deprecated license objects are not supported. Throws when neither given nor detected.

options.file

string, optional — File-name of license file. Detected from the files in the current working directory, in which case the first file matching /^licen[cs]e(?=$|\.)/i is used. If there is no given or found license file, but options.license is a known SPDX identifier, the URL to the license on spdx.org is used.

options.url

string, optional — URL to license holder. Detected from the package.json in the current working directory, supporting both object and string format of author. http:// is prepended if url starts without HTTP or HTTPS protocol.

options.ignoreFinalDefinitions

Ignore final definitions otherwise in the section (boolean, default: true).

Detection

Detection of package.json and files in the current working directory is based on the current working directory as set on the given vfile.

If you want to set the cwd yourself (the default is process.cwd()), you can pass in a vfile or vfile options to .process like so:

var fs = require('fs')
var path = require('path')
var remark = require('remark')
var license = require('remark-license')

remark()
  .use(license)
  .process(
    {
      cwd: path.join('.', 'some', 'path', 'to', 'a', 'directory'),
      contents: fs.readFileSync('example.md')
    },
    function(err, file) {
      if (err) throw err
      console.log(String(file))
    }
  )

Contribute

See contributing.md in remarkjs/remark for ways to get started.

This organisation has a Code of Conduct. By interacting with this repository, organisation, or community you agree to abide by its terms.

License

MIT © Titus Wormer

Keywords

FAQs

Last updated on 20 Nov 2018

Did you know?

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc