• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hexojs / hexo-util / 16650178400

31 Jul 2025 01:21PM UTC coverage: 73.042% (-23.8%) from 96.875%
16650178400

Pull #426

github

web-flow
Merge ca6058b70 into d497bc760
Pull Request #426: build: restructure for dual ESM/CJS output, update tooling, and enhance utilities

811 of 1128 branches covered (71.9%)

1593 of 2027 new or added lines in 40 files covered. (78.59%)

6 existing lines in 1 file now uncovered.

5289 of 7241 relevant lines covered (73.04%)

69.15 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.59
/scripts/build_highlight_alias.mjs
1
import hljs from 'highlight.js';
1✔
2
import fs from 'fs';
1✔
3
import path from 'path';
1✔
4
import { fileURLToPath } from 'url';
1✔
5

1✔
6
const __filename = fileURLToPath(import.meta.url);
1✔
7
const __dirname = path.dirname(__filename);
1✔
8

1✔
9
const languages = hljs.listLanguages();
1✔
10
const result = {
1✔
11
  languages: languages,
1✔
12
  aliases: {}
1✔
13
};
1✔
14

1✔
15
languages.forEach(lang => {
1✔
16
  result.aliases[lang] = lang;
192✔
17

192✔
18
  const aliases = hljs.getLanguage(lang).aliases;
192✔
19

192✔
20
  if (aliases) {
192✔
21
    aliases.forEach(alias => {
107✔
22
      result.aliases[alias] = lang;
181✔
23
    });
107✔
24
  }
107✔
25
});
1✔
26

1✔
27
const outputPaths = [
1✔
28
  path.join(__dirname, '../highlight_alias.json'),
1✔
29
  path.join(__dirname, '../dist/highlight_alias.json')
1✔
30
];
1✔
31

1✔
32
outputPaths.forEach(outputPath => {
1✔
33
  fs.mkdirSync(path.dirname(outputPath), { recursive: true });
2✔
34
  fs.writeFileSync(outputPath, JSON.stringify(result));
2✔
35
});
1✔
36

1✔
37
// Build the TypeScript file for import
1✔
38
const tsOutputPath = path.join(__dirname, '../lib/highlight_alias.ts');
1✔
39
const tsContent = `// This file is auto-generated by scripts/build_highlight_alias.mjs\nexport default ${JSON.stringify(result, null, 2)} as const;\n`;
1✔
40
fs.mkdirSync(path.dirname(tsOutputPath), { recursive: true });
1✔
41
fs.writeFileSync(tsOutputPath, tsContent);
1✔
42

1✔
43
// Fix the ESM import for compiled lib/highlight.ts
1✔
44
const srcJs = path.join(__dirname, '../dist/esm/highlight_esm.js');
1✔
45
const destJs = path.join(__dirname, '../dist/esm/highlight.js');
1✔
46
if (fs.existsSync(srcJs)) {
1!
NEW
47
  fs.renameSync(srcJs, destJs);
×
NEW
48
}
×
49

1✔
50
const srcDts = path.join(__dirname, '../dist/esm/highlight_esm.d.ts');
1✔
51
const destDts = path.join(__dirname, '../dist/esm/highlight.d.ts');
1✔
52
if (fs.existsSync(srcDts)) {
1!
NEW
53
  fs.renameSync(srcDts, destDts);
×
NEW
54
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc