Comparing version 0.1.0 to 0.1.1
@@ -10,6 +10,5 @@ /*! | ||
var languages = require('./lang.json'); | ||
var languages = module.exports = require('./lang.json'); | ||
module.exports = function (extension) { | ||
languages.lang = function (extension) { | ||
extension = extension.replace(/\./, ''); | ||
@@ -25,3 +24,3 @@ for (var lang in languages) { | ||
module.exports.ext = function (lang) { | ||
languages.ext = function (lang) { | ||
lang = lang.toLowerCase(); | ||
@@ -28,0 +27,0 @@ return languages[lang]; |
{ | ||
"name": "lang-map", | ||
"description": "Get the language associated with a file extension or the extensions associated with a language using the data from GitHub's [Linguist YAML file](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml)", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"homepage": "https://github.com/jonschlinkert/lang-map", | ||
@@ -6,0 +6,0 @@ "author": { |
17
test.js
@@ -10,16 +10,21 @@ /*! | ||
var language = require('./'); | ||
var languages = require('./'); | ||
var assert = require('assert'); | ||
describe('lang-map', function () { | ||
it('should return the full list of languages.', function () { | ||
assert.equal(typeof languages, 'object'); | ||
}); | ||
it('should return the language matching the given extension.', function () { | ||
assert.equal(language('js'), 'javascript'); | ||
assert.equal(language('.js'), 'javascript'); | ||
assert.equal(language('py'), 'python'); | ||
assert.equal(languages.lang('js'), 'javascript'); | ||
assert.equal(languages.lang('.js'), 'javascript'); | ||
assert.equal(languages.lang('py'), 'python'); | ||
}); | ||
it('should return the extensions matching the given language.', function () { | ||
assert.deepEqual(language.ext('asciidoc'), ["asciidoc", "adoc", "asc"]); | ||
assert.deepEqual(language.ext('python'), ["py", "gyp", "lmi", "pyde", "pyt", "pyw", "wsgi", "xpy"]); | ||
assert.deepEqual(languages.ext('asciidoc'), ["asciidoc", "adoc", "asc"]); | ||
assert.deepEqual(languages.ext('python'), ["py", "gyp", "lmi", "pyde", "pyt", "pyw", "wsgi", "xpy"]); | ||
}); | ||
}); |
19411
12
1245