Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use node.js api rather than unix commands #1488

Merged
merged 4 commits into from Feb 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions package.json
Expand Up @@ -58,11 +58,10 @@
"babel:build": "babel src -d js --source-maps -q",
"babel:watch": "babel src -d js --watch --source-maps",
"build:respec-w3c-common": "node ./tools/builder.js --profile=w3c-common",
"build": "npm run snyk-protect && npm run copydeps && npm run hb:build && npm run highlight:build && npm run babel:build",
"build:components": "npm run copydeps && node ./tools/build-components.js && npm run babel:build",
"build": "npm run snyk-protect && npm run build:components",
"copydeps": "node ./tools/copydeps.js",
"handlebars": "handlebars",
"hb:build": "node ./tools/expandpaths.js -a js/*/templates/*.html js/*/templates/*.css js/core/templates/webidl-contiguous/*.html | xargs handlebars -f js/templates.js",
"highlight:build": "hljs -n --output js/deps/ xml javascript css http markdown json abnf && mv -f js/deps/highlight.pack.js js/deps/highlight.js",
"karma": "karma start --single-run",
"release": "node ./tools/release.js",
"server": "npm start",
Expand Down
22 changes: 22 additions & 0 deletions tools/build-components.js
@@ -0,0 +1,22 @@
const { promisify } = require("util");
const exec = promisify(require("child_process").exec);
const move = require("fs-extra").move;
const glob = require("glob");

(async () => {
await buildHandlebars();
await buildHighlight();
})();

async function buildHandlebars() {
const paths = ["js/*/templates/*.html", "js/*/templates/*.css", "js/core/templates/webidl-contiguous/*.html"]
.map(path => glob.sync(path, { nonull: true }))
.reduce((res, file) => res.concat(file), [])
.join(" ");
await exec(`handlebars ${paths} -a -f js/templates.js`);
}

async function buildHighlight() {
await exec("hljs -n --output js/deps/ xml javascript css http markdown json abnf");
await move("js/deps/highlight.pack.js", "js/deps/highlight.js", { overwrite: true });
}
11 changes: 0 additions & 11 deletions tools/expandpaths.js

This file was deleted.