Skip to content

Commit 2fcef5f

Browse files
committed
move 'themes' task to node script
1 parent 6efa67f commit 2fcef5f

19 files changed

+70
-123
lines changed

Gruntfile.js

Lines changed: 0 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -31,34 +31,6 @@ module.exports = function(grunt) {
3131
return data;
3232
}
3333

34-
function processJupyterFiles() {
35-
const files = grunt.file.expand({
36-
filter: "isFile",
37-
cwd: "themes/jupyter"
38-
}, ["*"]);
39-
files.forEach(file => {
40-
const theme = grunt.file.read(`themes/jupyter/${file}`);
41-
grunt.file.write(`themes/jupyter/${file}`, replaceCSSMatches(theme));
42-
});
43-
}
44-
45-
// :any() has been deprecated, and :matches() is not fully supported
46-
// this is a simple replace method.. it'll handle `:matches .selector`, but
47-
// not `selector :matches()`
48-
// `:matches()` renamed to `:is()`
49-
// see https://developer.mozilla.org/en-US/docs/Web/CSS/:is
50-
function replaceCSSMatches(theme) {
51-
return theme.replace(/:is\(([^)]+)\)\s([^,{]+)(,|{)/gm, (_, matches, selector, separator) => {
52-
let result = "";
53-
const m = matches.split(/\s*,\s*/);
54-
const last = m.length - 1;
55-
m.forEach((match, index) => {
56-
result += `${match} ${selector.trim()}${index >= last && separator === "{" ? " {" : ", "}`;
57-
});
58-
return result;
59-
});
60-
}
61-
6234
// modified from http://stackoverflow.com/a/5624139/145346
6335
function hexToRgb(hex) {
6436
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
@@ -201,69 +173,9 @@ module.exports = function(grunt) {
201173
options: {replacements: "<%= config.replacements %>"}
202174
}
203175
},
204-
clean: {
205-
cssmins: {
206-
src: [
207-
// don't clean combined theme files (older method) until
208-
// we can be assured that everyone has updated GitHub-Dark-Script
209-
// "themes/*.min.css",
210-
"themes/**/*.min.css"
211-
]
212-
}
213-
},
214176
exec: {
215177
usercss: "node tools/usercss.js",
216178
},
217-
cssmin: {
218-
codemirror: {
219-
files: [{
220-
expand: true,
221-
cwd: "themes/src/codemirror/",
222-
src: "*.css",
223-
dest: "themes/codemirror",
224-
ext: ".min.css"
225-
}],
226-
options: {
227-
level: {
228-
2: {
229-
all: true,
230-
specialComments: "all"
231-
}
232-
}
233-
}
234-
},
235-
github: {
236-
files: [{
237-
expand: true,
238-
cwd: "themes/src/github/",
239-
src: "*.css",
240-
dest: "themes/github",
241-
ext: ".min.css"
242-
}],
243-
options: {
244-
// Don't use level 2; background *must* be the first entry; see #599
245-
keepSpecialComments: "*",
246-
advanced: false
247-
}
248-
},
249-
jupyter: {
250-
files: [{
251-
expand: true,
252-
cwd: "themes/src/jupyter/",
253-
src: "*.css",
254-
dest: "themes/jupyter",
255-
ext: ".min.css"
256-
}],
257-
options: {
258-
level: {
259-
2: {
260-
all: true,
261-
specialComments: "all"
262-
}
263-
}
264-
}
265-
}
266-
},
267179
wrap: {
268180
mozrule: {
269181
files: {"<%= config.buildFile %>": "<%= config.buildFile %>"},
@@ -275,8 +187,6 @@ module.exports = function(grunt) {
275187
});
276188

277189
grunt.loadNpmTasks("grunt-string-replace");
278-
grunt.loadNpmTasks("grunt-contrib-clean");
279-
grunt.loadNpmTasks("grunt-contrib-cssmin");
280190
grunt.loadNpmTasks("grunt-wrap");
281191
grunt.loadNpmTasks("grunt-exec");
282192

@@ -299,19 +209,4 @@ module.exports = function(grunt) {
299209
"exec:usercss"
300210
]);
301211
});
302-
303-
// build custom minified GitHub-Dark style
304-
grunt.registerTask("themes", "Rebuild minified theme files", () => {
305-
grunt.task.run([
306-
"clean:cssmins",
307-
"cssmin:codemirror",
308-
"cssmin:github",
309-
"cssmin:jupyter",
310-
"jupyter"
311-
]);
312-
});
313-
314-
grunt.registerTask("jupyter", "Replacing :is() in Jupyter files", () => {
315-
processJupyterFiles();
316-
});
317212
};

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ To develop, first install [Node.js](https://nodejs.org) 12 or greater, then inst
115115

116116
- `npx grunt`: The default grunt task builds a custom theme using a provided `build.json` file. See the [wiki](https://github.com/StylishThemes/GitHub-Dark/wiki/Build) for details.
117117
- `npm run usercss`: Build a [Usercss](https://github.com/openstyles/stylus/wiki/Usercss) style.
118-
- `npx grunt themes`: Parse all theme files and combine them into minified styles in the `themes` directory.
118+
- `npm run themes`: Parse all theme files and combine them into minified styles in the `themes` directory.
119119
- `npm run clean`: Reformat `github-dark.css` to conform the style guide.
120120
- `npm run lint`: Run Stylelint on `github-dark.css`.
121121
- `npm run authors`: Regenerate the `AUTHORS` file based on git history.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,18 @@
1919
"patch": "npm run lint && npm run usercss && versions -p -d -C patch github-dark.css github-dark.user.css",
2020
"perfectionist": "perfectionist github-dark.css github-dark.css --indentSize 2 --maxAtRuleLength 250",
2121
"test": "npm run lint",
22+
"themes": "node tools/themes.js",
2223
"update": "updates -cu && npm install",
2324
"usercss": "grunt usercss"
2425
},
2526
"devDependencies": {
27+
"clean-css-cli": "4.3.0",
2628
"css": "2.2.4",
2729
"css-mediaquery": "0.1.2",
2830
"eslint": "6.7.2",
2931
"eslint-config-silverwind": "5.0.3",
32+
"fast-glob": "3.1.1",
3033
"grunt": "1.0.4",
31-
"grunt-contrib-clean": "2.0.0",
32-
"grunt-contrib-cssmin": "3.0.0",
3334
"grunt-exec": "3.0.0",
3435
"grunt-string-replace": "1.3.1",
3536
"grunt-wrap": "0.3.1",

themes/codemirror/ambiance.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

themes/codemirror/base16-ocean-dark.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

themes/codemirror/cobalt.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

themes/codemirror/dracula.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)