-
-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathplugin.mjs
57 lines (46 loc) · 1.15 KB
/
plugin.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import fs from 'fs';
import path from 'path';
import yaml from 'js-yaml';
import { codeImport } from 'remark-code-import';
import interpret from '../index.js';
// Exporting this so it can be used by remark-cli
export default codeImport;
// Also preparing the files we need for the README
var config = {
sortKeys: true,
skipInvalid: true,
replacer: function (key, value) {
// Top-level object
if (key === '') {
return value;
}
if (key.startsWith('.')) {
return Array.isArray(value) ? value : [value];
}
if (value === null) {
return 'built-in node.js loader';
}
if (typeof value !== 'string') {
return value.module;
}
if (value.includes('mjs-stub')) {
return 'interpret/mjs-stub';
}
if (value.includes('cjs-stub')) {
return 'interpret/cjs-stub';
}
return value;
},
};
var extensions = yaml.dump(interpret.extensions, config);
var jsVariants = yaml.dump(interpret.jsVariants, config);
fs.writeFileSync(
new URL('./extensions.yaml', import.meta.url),
extensions,
'utf8'
);
fs.writeFileSync(
new URL('./jsVariants.yaml', import.meta.url),
jsVariants,
'utf8'
);