Skip to content

Commit

Permalink
Fix crash when specifying categories alongside hidden languages
Browse files Browse the repository at this point in the history
  • Loading branch information
Nixinova committed Aug 29, 2021
1 parent 5880395 commit 431cb20
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 13 deletions.
12 changes: 11 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
# Changelog

## 1.9.1
*2021-08-29*
- Fixed a crash occurring when using both the `categories` and `ignoreLanguages` options together.

## 1.9.0
- Add `ignoreLanguages` option to configure which languages to ignore.
*2021-08-29*
- Added `ignoreLanguages` option to configure which languages to ignore.
- Added alias `ignoreFiles` for option `ignore`.
- Added CLI argument `--tree` to traverse the output tree to a specific object instead of logging the entire results.
- Deprecated option `ignore` as it is now ambiguous.

## 1.8.2
*2021-08-28*
- Fixed known vendored files not being removed from output.

## 1.8.1
*2021-08-28*
- Fixed input folder paths being case sensitive.
- Fixed dotfiles not showing up in the output.

## 1.8.0
*2021-08-24*
- Added support for the first argument to `analyse()` to be an array of paths.

## 1.7.1
*2021-08-21*
- Changed file paths specified in option `ignore` to remain hidden even when `keepVendored` is enabled.
- Fixed file results not being listed when using globbed input.
- Fixed command-line arguments not being fully normalised.

## 1.7.0
*2021-08-19*
- Added `categories` option to control which language categories (`data`, `markup`, `programming`, and/or `prose`) should be included in the output.
- Fixed some files being incorrectly classified as binary.

Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "linguist-js",
"version": "1.9.0",
"version": "1.9.1",
"description": "Analyse languages used in a folder. Powered by GitHub Linguist, although it doesn't need to be installed.",
"main": "dist/index.js",
"bin": {
Expand Down
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ let { count, results, languages } = linguist(folder, options);

### Command-line

CLI usage requires `commander`, which is marked as an optional dependency.
If an error saying `Cannot find module 'commander'` is thrown, run `npm install commander --no-save`.

```
linguist --analyze [<folder>] [<...options>]
linguist --help
Expand Down
2 changes: 0 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { program } from 'commander';

import linguist from './index';

if (typeof program === 'undefined') throw `Dependency 'commander' is not installed.`;

program
.name('linguist --analyze')
.usage('[<folder>] [<options...>]')
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ async function analyse(input?: string | string[], opts: T.Options = {}): Promise
const categories: S.LanguageType[] = ['data', 'markup', 'programming', 'prose'];
const hiddenCategories = categories.filter(cat => !opts.categories!.includes(cat));
for (const [file, lang] of Object.entries(finalResults)) {
if (!hiddenCategories.some(cat => lang && langData[lang].type === cat)) continue;
if (!hiddenCategories.some(cat => lang && langData[lang]?.type === cat)) continue;
delete finalResults[file];
if (lang) delete languages.all[lang];
}
Expand Down

0 comments on commit 431cb20

Please sign in to comment.