Skip to content

Commit

Permalink
Transition some scripts to ES6 style imports
Browse files Browse the repository at this point in the history
  • Loading branch information
peaBerberian committed Feb 21, 2024
1 parent bf5163c commit 4047ad4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
19 changes: 10 additions & 9 deletions scripts/generate_demo_list.js → scripts/generate_demo_list.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@
* all the right links.
*/

const fs = require("fs");
const path = require("path");
const { encode } = require("html-entities");
const semver = require("semver");
import { lstatSync, readdirSync, existsSync, writeFileSync } from "fs";
import { join } from "path";
import { encode } from "html-entities";
import * as semver from "semver";
import { getUrlsForVersion } from "./generate_demo_list.mjs";

const INITIAL_PATH = "./versions";

Expand All @@ -48,7 +49,7 @@ function sortVersions(versions) {
}

function isDirectory(source) {
return fs.lstatSync(source).isDirectory();
return lstatSync(source).isDirectory();
}

export function getUrlsForVersion(initialPath, version) {
Expand Down Expand Up @@ -83,12 +84,12 @@ const head = `<head>

let body = "<body>";

const files = fs.readdirSync(INITIAL_PATH);
const files = readdirSync(INITIAL_PATH);
const versions = [];
for (let i = 0; i < files.length; i++) {
const fileName = files[i];
const filePath = path.join(INITIAL_PATH, fileName);
if (isDirectory(filePath) && fs.existsSync(path.join(filePath, "demo"))) {
const filePath = join(INITIAL_PATH, fileName);
if (isDirectory(filePath) && existsSync(join(filePath, "demo"))) {
versions.push(fileName);
}
}
Expand Down Expand Up @@ -127,4 +128,4 @@ const html = "<html>" +
body +
"<html>";

fs.writeFileSync("./demo_page_by_version.html", html);
writeFileSync("./demo_page_by_version.html", html);
File renamed without changes.
8 changes: 4 additions & 4 deletions scripts/update_gh-pages_demo
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ cp -r demo/full/styles $tmpStylesDir -v
cp demo/full/bundle.js $tmpDemoFile -v
cp demo/full/index.html $tmpIndexFile -v
cp demo/full/plus.ico $tmpFaviconFile -v
cp scripts/generate_demo_list.js $tmpDemoList -v
cp scripts/generate_demo_list.mjs $tmpDemoList -v

# update gh-pages
git checkout gh-pages
Expand All @@ -71,10 +71,10 @@ mv $tmpDemoFile "versions/$current_version/demo/bundle.js"
mv $tmpFontsDir/fonts "versions/$current_version/demo/fonts"
mv $tmpAssetsDir/assets "versions/$current_version/demo/assets"
mv $tmpStylesDir/styles "versions/$current_version/demo/styles"
mv $tmpDemoList generate_demo_list.js
mv $tmpDemoList generate_demo_list.mjs

node generate_demo_list.js
rm generate_demo_list.js
node generate_demo_list.mjs
rm generate_demo_list.mjs

if [ -n "$(git status --porcelain bundle.js styles fonts assets index.html "versions/$current_version/demo" demo_page_by_version.html)" ]; then
echo "-- Current Status on gh-pages: --"
Expand Down
8 changes: 4 additions & 4 deletions scripts/update_gh-pages_doc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ tmpDir=$(mktemp -d)
tmpDocList=$(mktemp)

cp -r doc/generated/* $tmpDir
cp scripts/generate_documentation_list.js $tmpDocList -v
cp scripts/generate_documentation_list.mjs $tmpDocList -v

# update gh-pages
git checkout gh-pages
Expand All @@ -50,10 +50,10 @@ rm -rf "versions/$current_version/doc"
mkdir -p "versions/$current_version/doc"
rm -rf doc
mv $tmpDir/* "versions/$current_version/doc"
mv $tmpDocList generate_documentation_list.js
mv $tmpDocList generate_documentation_list.mjs

node generate_documentation_list.js
rm generate_documentation_list.js
node generate_documentation_list.mjs
rm generate_documentation_list.mjs

if [ -n "$(git status --porcelain doc "versions/$current_version/doc" documentation_pages_by_version.html)" ]; then
echo "-- Current Status on gh-pages: --"
Expand Down

0 comments on commit 4047ad4

Please sign in to comment.