Skip to content

Commit 9672ffa

Browse files
committed
Require Node.js 18
1 parent d326f72 commit 9672ffa

File tree

3 files changed

+103
-99
lines changed

3 files changed

+103
-99
lines changed

cli.js

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ const cli = meow(
4949
flags: {
5050
theme: {
5151
type: 'string',
52-
alias: ['type'],
52+
aliases: [
53+
'type',
54+
],
5355
},
5456
light: {
5557
type: 'string',
@@ -76,69 +78,67 @@ const cli = meow(
7678
},
7779
);
7880

79-
(async () => {
80-
const {
81-
theme,
81+
const {
82+
theme,
83+
list,
84+
preserveVariables,
85+
onlyStyle,
86+
onlyVariables,
87+
rootSelector,
88+
} = cli.flags;
89+
90+
let {light, dark} = cli.flags;
91+
92+
/*
93+
| Theme | Light | Dark | Outcome |
94+
| ----- | ----- | ---- | ---------------------------------- |
95+
| ✓ | | | Single mode, use Theme |
96+
| ✓ | ✓ | | Not allowed, can't determine theme |
97+
| ✓ | | ✓ | Not allowed, can't determine theme |
98+
| ✓ | ✓ | ✓ | Not allowed, can't determine theme |
99+
| | | | Auto, default themes |
100+
| | ✓ | | Single mode, use Light |
101+
| | | ✓ | Single mode, use Dark |
102+
| | ✓ | ✓ | Auto, use Light and Dark |
103+
| | ✓ | ✓ | Single mode if Light === Dark |
104+
| auto | | | Auto, default themes |
105+
| auto | ✓ | | Auto, use Light, default dark |
106+
| auto | | ✓ | Auto, use Dark, default light |
107+
| auto | ✓ | ✓ | Auto, use Light and Dark |
108+
| auto | ✓ | ✓ | Single mode if Light === Dark |
109+
*/
110+
111+
// Use "single" mode when type is a theme name other than 'auto'
112+
if (theme && theme !== 'auto') {
113+
if (light || dark) {
114+
console.error('You may not specify light and/or dark unless type/theme is set to "auto"');
115+
exit(1);
116+
}
117+
118+
light = theme;
119+
dark = theme;
120+
}
121+
122+
// If only light or dark was specified set the other to force "single mode"
123+
if (!theme && light && !dark) {
124+
dark = light;
125+
} else if (!theme && !light && dark) {
126+
light = dark;
127+
}
128+
129+
if (rootSelector === '') {
130+
console.error('--rootSelector cannot be an empty string');
131+
exit(1);
132+
}
133+
134+
console.log(
135+
await githubMarkdownCss({
136+
light,
137+
dark,
82138
list,
83139
preserveVariables,
84-
onlyStyle,
140+
onlyStyles: onlyStyle,
85141
onlyVariables,
86142
rootSelector,
87-
} = cli.flags;
88-
89-
let {light, dark} = cli.flags;
90-
91-
/*
92-
| Theme | Light | Dark | Outcome |
93-
| ----- | ----- | ---- | ---------------------------------- |
94-
| ✓ | | | Single mode, use Theme |
95-
| ✓ | ✓ | | Not allowed, can't determine theme |
96-
| ✓ | | ✓ | Not allowed, can't determine theme |
97-
| ✓ | ✓ | ✓ | Not allowed, can't determine theme |
98-
| | | | Auto, default themes |
99-
| | ✓ | | Single mode, use Light |
100-
| | | ✓ | Single mode, use Dark |
101-
| | ✓ | ✓ | Auto, use Light and Dark |
102-
| | ✓ | ✓ | Single mode if Light === Dark |
103-
| auto | | | Auto, default themes |
104-
| auto | ✓ | | Auto, use Light, default dark |
105-
| auto | | ✓ | Auto, use Dark, default light |
106-
| auto | ✓ | ✓ | Auto, use Light and Dark |
107-
| auto | ✓ | ✓ | Single mode if Light === Dark |
108-
*/
109-
110-
// Use "single" mode when type is a theme name other than 'auto'
111-
if (theme && theme !== 'auto') {
112-
if (light || dark) {
113-
console.error('You may not specify light and/or dark unless type/theme is set to "auto"');
114-
exit(1);
115-
}
116-
117-
light = theme;
118-
dark = theme;
119-
}
120-
121-
// If only light or dark was specified set the other to force "single mode"
122-
if (!theme && light && !dark) {
123-
dark = light;
124-
} else if (!theme && !light && dark) {
125-
light = dark;
126-
}
127-
128-
if (rootSelector === '') {
129-
console.error('--rootSelector cannot be an empty string');
130-
exit(1);
131-
}
132-
133-
console.log(
134-
await githubMarkdownCss({
135-
light,
136-
dark,
137-
list,
138-
preserveVariables,
139-
onlyStyles: onlyStyle,
140-
onlyVariables,
141-
rootSelector,
142-
}),
143-
);
144-
})();
143+
}),
144+
);

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"exports": "./index.js",
1818
"engines": {
19-
"node": ">=14.8"
19+
"node": ">=18"
2020
},
2121
"scripts": {
2222
"test": "xo && node test.js"
@@ -39,10 +39,10 @@
3939
],
4040
"dependencies": {
4141
"css": "^3.0.0",
42-
"got": "^11.8.2",
43-
"meow": "^10.1.1"
42+
"got": "^13.0.0",
43+
"meow": "^12.1.1"
4444
},
4545
"devDependencies": {
46-
"xo": "^0.46.4"
46+
"xo": "^0.56.0"
4747
}
4848
}

test.js

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,31 @@ import fs from 'node:fs';
22
import {renderMarkdown} from './utilities.js';
33
import githubMarkdownCss from './index.js';
44

5-
(async () => {
6-
fs.mkdirSync('dist', {recursive: true});
5+
fs.mkdirSync('dist', {recursive: true});
76

8-
fs.writeFileSync('dist/auto.css', await githubMarkdownCss());
9-
const themes = [
10-
'light',
11-
'light_high_contrast',
12-
'light_colorblind',
13-
'light_tritanopia',
14-
'dark',
15-
'dark_high_contrast',
16-
'dark_colorblind',
17-
'dark_tritanopia',
18-
'dark_dimmed',
19-
];
7+
fs.writeFileSync('dist/auto.css', await githubMarkdownCss());
208

21-
await Promise.all(themes.map(async theme => {
22-
fs.writeFileSync(`dist/${theme}.css`, await githubMarkdownCss({light: theme, dark: theme}));
23-
}));
24-
fs.writeFileSync('dist/auto_colorblind.css', await githubMarkdownCss({light: 'light_colorblind', dark: 'dark_colorblind'}));
9+
const themes = [
10+
'light',
11+
'light_high_contrast',
12+
'light_colorblind',
13+
'light_tritanopia',
14+
'dark',
15+
'dark_high_contrast',
16+
'dark_colorblind',
17+
'dark_tritanopia',
18+
'dark_dimmed',
19+
];
2520

26-
const fixture = await renderMarkdown();
27-
const html = `<!DOCTYPE html>
21+
await Promise.all(themes.map(async theme => {
22+
fs.writeFileSync(`dist/${theme}.css`, await githubMarkdownCss({light: theme, dark: theme}));
23+
}));
24+
25+
fs.writeFileSync('dist/auto_colorblind.css', await githubMarkdownCss({light: 'light_colorblind', dark: 'dark_colorblind'}));
26+
27+
const fixture = await renderMarkdown();
28+
29+
const html = `<!DOCTYPE html>
2830
<html>
2931
<head>
3032
<meta charset="utf-8">
@@ -44,19 +46,21 @@ ${fixture}
4446
</body>
4547
</html>
4648
`;
47-
fs.writeFileSync('dist/index.html', html);
4849

49-
// Demonstrate theme variable files switching with base css
50-
fs.mkdirSync('dist/vars', {recursive: true});
50+
fs.writeFileSync('dist/index.html', html);
5151

52-
fs.writeFileSync('dist/vars/base.css', await githubMarkdownCss({onlyStyles: true}));
53-
fs.writeFileSync('dist/vars/auto-vars.css', await githubMarkdownCss({onlyVariables: true}));
54-
fs.writeFileSync('dist/vars/auto_colorblind-vars.css', await githubMarkdownCss({light: 'light_colorblind', dark: 'dark_colorblind', onlyVariables: true}));
55-
await Promise.all(themes.map(async theme => {
56-
fs.writeFileSync(`dist/vars/${theme}-vars.css`, await githubMarkdownCss({light: theme, dark: theme, onlyVariables: true}));
57-
}));
52+
// Demonstrate theme variable files switching with base css
53+
fs.mkdirSync('dist/vars', {recursive: true});
5854

59-
const htmlVars = `<!DOCTYPE html>
55+
fs.writeFileSync('dist/vars/base.css', await githubMarkdownCss({onlyStyles: true}));
56+
fs.writeFileSync('dist/vars/auto-vars.css', await githubMarkdownCss({onlyVariables: true}));
57+
fs.writeFileSync('dist/vars/auto_colorblind-vars.css', await githubMarkdownCss({light: 'light_colorblind', dark: 'dark_colorblind', onlyVariables: true}));
58+
59+
await Promise.all(themes.map(async theme => {
60+
fs.writeFileSync(`dist/vars/${theme}-vars.css`, await githubMarkdownCss({light: theme, dark: theme, onlyVariables: true}));
61+
}));
62+
63+
const htmlVars = `<!DOCTYPE html>
6064
<html>
6165
<head>
6266
<meta charset="utf-8">
@@ -77,5 +81,5 @@ ${fixture}
7781
</body>
7882
</html>
7983
`;
80-
fs.writeFileSync('dist/vars/index.html', htmlVars);
81-
})();
84+
85+
fs.writeFileSync('dist/vars/index.html', htmlVars);

0 commit comments

Comments
 (0)