Skip to content

Commit

Permalink
move base16 themes into subdir
Browse files Browse the repository at this point in the history
  • Loading branch information
joshgoebel committed Apr 14, 2021
1 parent a046e34 commit f4cd6d5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
File renamed without changes.
30 changes: 25 additions & 5 deletions tools/build_browser.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const _ = require('lodash');
const fs = require("fs").promises;
const fss = require("fs");
const glob = require("glob-promise");
const path = require("path");
const zlib = require('zlib');
Expand All @@ -23,6 +24,14 @@ function buildHeader(args) {
` */`;
}

function sortByKey(array, key) {
return array.sort(function(a, b) {
const x = a[key];
const y = b[key];
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
});
}

function detailedGrammarSizes(languages) {
if (languages.length > 180) return;

Expand Down Expand Up @@ -120,10 +129,19 @@ async function renderIndex(languages, minify) {
count: categoryCounter.get(category)
}));

const css = await glob("styles/*.css", { cwd: "./src" });
const styles = css
.map((el) => ({ name: _.startCase(path.basename(el, ".css")), path: el }))
function nameForStyle(file) {
let name = _.startCase(path.basename(file, ".css"));
if (file.includes("base16/")) {
name = `Base16 / ${name}`;
}
return name;
}

const css = await glob("styles/**/*.css", { cwd: "./src" });
let styles = css
.map((el) => ({ name: nameForStyle(el), path: el }))
.filter((style) => style.name !== "Default");
styles = sortByKey(styles, "name");

renderTemplate("./demo/index.html", "./demo/index.html", {
categories,
Expand All @@ -144,11 +162,13 @@ async function installDocs() {
function installDemoStyles() {
log("Writing style files.");
mkdir("demo/styles");
mkdir("demo/styles/base16");

glob.sync("*", { cwd: "./src/styles" }).forEach((file) => {
glob.sync("**", { cwd: "./src/styles" }).forEach((file) => {
const stat = fss.statSync(`./src/styles/${file}`);
if (file.endsWith(".css")) {
installCleanCSS(`./src/styles/${file}`, `demo/styles/${file}`);
} else {
} else if (!stat.isDirectory) {
// images, backgrounds, etc
install(`./src/styles/${file}`, `demo/styles/${file}`);
}
Expand Down
13 changes: 9 additions & 4 deletions tools/build_node.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const fs = require("fs").promises;
const fss = require("fs");
const config = require("./build_config");
const glob = require("glob-promise");
const { getLanguages } = require("./lib/language");
const { install, mkdir } = require("./lib/makestuff");
const { filter } = require("./lib/dependencies");
Expand Down Expand Up @@ -58,8 +60,8 @@ async function buildLanguages(languages) {

async function buildNode(options) {
mkdir("lib/languages");
mkdir("scss");
mkdir("styles");
mkdir("scss/base16");
mkdir("styles/base16");
mkdir("types");

install("./LICENSE", "LICENSE");
Expand All @@ -68,8 +70,11 @@ async function buildNode(options) {
install("./src/core.d.ts","lib/core.d.ts");

log("Writing styles.");
const styles = await fs.readdir("./src/styles/");
styles.forEach((file) => {
// const styles = await fs.readdir("./src/styles/");
glob.sync("**", { cwd: "./src/styles" }).forEach((file) => {
const stat = fss.statSync(`./src/styles/${file}`);
if (stat.isDirectory()) return;

install(`./src/styles/${file}`, `styles/${file}`);
install(`./src/styles/${file}`, `scss/${file.replace(".css", ".scss")}`);
});
Expand Down

0 comments on commit f4cd6d5

Please sign in to comment.