Skip to content
This repository has been archived by the owner on Nov 22, 2021. It is now read-only.
/ fang Public archive

A tiny utility to get language information about a file.

License

Notifications You must be signed in to change notification settings

allmarkedup/fang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fang

A tiny utility to get language information about a file.

Simply checks the file extension against Github's list of known languages. If you need something more robust (but likely slower) then other solutions are available :-)

Installation

$ npm install @allmarkedup/fang --save

Usage

The fang module exports a single function with the following signature:

fang(<path-to-file>);

And returns and object with known information about the language, or undefined if not recognised). For example:

const fang = require('@allmarkedup/fang');

console.dir(fang('assets/styles/main.scss'));

// Outputs:
// {
//     "name":  "SCSS",           // Language name
//     "type": "programming",     // language type - programming, data, markup etc
//     "color": "#CF649A",        // Github UI color
//     "extensions": [".scss"],   // Array of known extensions
//     "aliases": [],             // Array of known aliases
//     "language_id": 32,         // Github language ID
// }

Credits

All language information is taken from Github's Linguist gem.

About

A tiny utility to get language information about a file.

Resources

License

Stars

Watchers

Forks

Packages

No packages published