@tanem/authors

Generates a list of authors in a format suitable for inclusion in an AUTHORS file.

Usage no npm install needed!

<script type="module">
  import tanemAuthors from 'https://cdn.skypack.dev/@tanem/authors';
</script>

README

authors

npm version build status coverage status npm downloads

Generates a list of authors in a format suitable for inclusion in an AUTHORS file.

Usage

Usage: authors [options]

Generates a list of authors in a format suitable for inclusion in an AUTHORS file.

Options:
  -V, --version   output the version number
  -n, --numbered  sort by number of commits per author
  -h, --help      output usage information

Examples:
  $ authors
  $ authors -n

The list of authors is printed to stdout, so can be redirected to a file:

$ authors > AUTHORS

API

authors([options])

Returns a Promise that will be resolved with a list of authors sorted alphabetically by author name. If an error occurs during execution, the Promise is rejected with an Error object.

Arguments

  • options - Optional An object containing the optional arguments defined below. Defaults to {}.
    • isNumbered - Optional Sort the list by number of commits per author.

Example

// Note: The `fs.promises` API was added in Node.js v10.0.0.
import { promises as fs } from 'fs';
import path from 'path';
import authors from '@tanem/authors';

(async () => {
  try {
    const result = await authors({ isNumbered: true });
    await fs.writeFile(path.join(__dirname, 'AUTHORS'), result, 'utf-8');
  } catch (error) {
    console.error(error);
  }
})();

authors.sync([options])

Synchronously returns a list of authors sorted alphabetically by author name. If an error occurs during execution, an Error object will be thrown.

Arguments

  • options - Optional An object containing the optional arguments defined below. Defaults to {}.
    • isNumbered - Optional Sort the list by number of commits per author.

Example

import fs from 'fs';
import path from 'path';
import authors from '@tanem/authors';

try {
  const result = authors.sync({ isNumbered: true });
  fs.writeFileSync(path.join(__dirname, 'AUTHORS'), result, 'utf-8');
} catch (error) {
  console.error(error);
}

Installation

$ npm install @tanem/authors --save-dev

License

MIT