Skip to content

Commit

Permalink
support comments in rules
Browse files Browse the repository at this point in the history
  • Loading branch information
ZYinMD committed Dec 5, 2018
1 parent fe238d3 commit ea4664e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 3 additions & 1 deletion scripts/buildRules.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
const fs = require('fs');
const path = require('path');
const json = require('comment-json');

function buildRules(themeName) {
const rulesDir = path.join(__dirname, '../syntax-highlighting-rules', themeName);
const ruleFiles = fs.readdirSync(rulesDir);
return ruleFiles.reduce((accumulator, fileName) => {
const filePath = path.join(rulesDir, fileName);
accumulator = accumulator.concat(JSON.parse(fs.readFileSync(filePath, 'utf8')));
const rule = json.parse(fs.readFileSync(filePath, 'utf8'), null, true); // strip comments
accumulator = accumulator.concat(rule);
return accumulator;
}, [])
}
Expand Down
14 changes: 7 additions & 7 deletions scripts/tweak.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ if (!rules)
for (let i of rules)
i.settings.foreground = pallette[i.settings.foreground];

const officialThemeName = (() => {
switch (themeName) {
case 'sepia':
const officialThemeName = (() => {
switch (themeName) {
case 'sepia':
return 'Sepia';
case 'sepia-from-cuttle-fish':
case 'sepia-from-cuttle-fish':
return 'Sepia from Cuttlefish';
default:
default:
break;
}
})();
}
})();

// create keys in userSettings if not existed:
userSettings['editor.tokenColorCustomizations'] = userSettings['editor.tokenColorCustomizations'] || {};
Expand Down

0 comments on commit ea4664e

Please sign in to comment.