Skip to content

Commit

Permalink
fix: override Kotlin ace mode to kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastiaanYN committed Feb 29, 2020
1 parent 2f1cb16 commit e798f1c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 6 deletions.
6 changes: 6 additions & 0 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"eslint-plugin-eslint-comments": "^3.1.2",
"eslint-plugin-import": "^2.19.1",
"eslint-plugin-jsdoc": "^15.8.0",
"js-yaml": "^3.13.1"
"js-yaml": "^3.13.1",
"merge": "^1.2.1"
},
"files": [
"dist"
Expand Down
32 changes: 27 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
const fs = require('fs');
const { join } = require('path');
const yaml = require('js-yaml');
const merge = require('merge');

const download = require('./download.js');
const config = require('../config.json');

Expand All @@ -9,6 +13,14 @@ const indexFile = `
module.exports.languages = require('./languages.json');
`;

function mergeOverrides(linguist) {
const overrides = yaml.safeLoad(
fs.readFileSync(join(__dirname, 'override.yml')),
);

return merge.recursive(linguist, overrides);
}

function transformLanguage(name, data) {
return {
name,
Expand Down Expand Up @@ -38,14 +50,24 @@ function transformLanguages(githubLinguist) {
}

download(config.url).then((githubLinguist) => {
const linguist = transformLinguist(githubLinguist);
const languages = transformLanguages(githubLinguist);
const linguist = mergeOverrides(githubLinguist);

if (!fs.existsSync(DIST_DIR)) {
fs.mkdirSync(DIST_DIR);
}

fs.writeFileSync(`${DIST_DIR}/index.js`, indexFile);
fs.writeFileSync(`${DIST_DIR}/linguist.json`, JSON.stringify(linguist, null, 2));
fs.writeFileSync(`${DIST_DIR}/languages.json`, JSON.stringify(languages, null, 2));
fs.writeFileSync(
join(DIST_DIR, 'index.js'),
indexFile,
);

fs.writeFileSync(
join(DIST_DIR, 'linguist.json'),
JSON.stringify(transformLinguist(linguist), null, 2),
);

fs.writeFileSync(
join(DIST_DIR, 'languages.json'),
JSON.stringify(transformLanguages(linguist), null, 2),
);
});
2 changes: 2 additions & 0 deletions src/override.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Kotlin:
ace_mode: kotlin

0 comments on commit e798f1c

Please sign in to comment.