Improve error messages when packages are not installed (#764).
This commit is contained in:
parent
acf6477d78
commit
1b9eef5b7a
5 changed files with 45 additions and 33 deletions
|
@ -281,8 +281,8 @@ Please note that, due to the complex interactions when forming ligations, cherry
|
|||
|
||||
To build Iosevka you should:
|
||||
|
||||
1. Ensure that [`nodejs`](http://nodejs.org) (≥ 12.16.0) and [`ttfautohint`](http://www.freetype.org/ttfautohint/) are present.
|
||||
2. Install necessary libs by `npm install`. If you’ve installed them, upgrade to the latest.
|
||||
1. Ensure that [`nodejs`](http://nodejs.org) (≥ 12.16.0) and [`ttfautohint`](http://www.freetype.org/ttfautohint/) are present, and accessible from `PATH`.
|
||||
2. Run `npm install`. This command will install **all** the NPM dependenceis, and will also validate whether external dependencies are present.
|
||||
3. `npm run build -- contents::iosevka`.
|
||||
|
||||
You will find TTFs, as well as WOFF(2) web fonts and one Webfont CSS in the `dist/` directory.
|
||||
|
|
|
@ -3,10 +3,9 @@
|
|||
"version": "4.0.0",
|
||||
"main": "./font-src/index.js",
|
||||
"scripts": {
|
||||
"build": "verda -f verdafile.js",
|
||||
"build": "node utility/ensure-verda-exists && verda -f verdafile.js",
|
||||
"bump-ver": "node utility/update-package-json-version/index",
|
||||
"clean": "verda -f verdafile.js clean",
|
||||
"install": "node utility/check-env"
|
||||
"clean": "node utility/ensure-verda-exists && verda -f verdafile.js clean"
|
||||
},
|
||||
"dependencies": {
|
||||
"@iarna/toml": "^2.2.5",
|
||||
|
@ -23,7 +22,7 @@
|
|||
"stylus": "^0.54.8",
|
||||
"toposort": "^2.0.2",
|
||||
"typo-geom": "^0.11.0",
|
||||
"verda": "^1.1.2",
|
||||
"verda": "^1.2.0",
|
||||
"wawoff2": "^1.0.2",
|
||||
"which": "^2.0.2"
|
||||
},
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
const which = require("which");
|
||||
const FgRed = "\x1b[31m";
|
||||
const FgGreen = "\x1b[32m";
|
||||
const FgYellow = "\x1b[33m";
|
||||
const Reset = "\x1b[0m";
|
||||
|
||||
console.log("Checking External Dependencies");
|
||||
check("ttfautohint");
|
||||
|
||||
function check(util) {
|
||||
try {
|
||||
which.sync(util);
|
||||
console.error(FgGreen + ` * External dependency <${util}> is present.` + Reset);
|
||||
} catch (e) {
|
||||
console.error(FgRed + ` * External dependency <${util}> is not found.` + Reset);
|
||||
}
|
||||
}
|
23
utility/ensure-verda-exists.js
Normal file
23
utility/ensure-verda-exists.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
"use strict";
|
||||
|
||||
const FgRed = "\x1b[31m";
|
||||
const FgYellow = "\x1b[33m";
|
||||
const Reset = "\x1b[0m";
|
||||
|
||||
const os = require("os");
|
||||
const shellWord = os.platform() === "win32" ? "command prompt" : "shell";
|
||||
|
||||
// Check packages are present
|
||||
try {
|
||||
require("verda/package.json");
|
||||
require("semver/package.json");
|
||||
require("which/package.json");
|
||||
require("@iarna/toml/package.json");
|
||||
} catch (e) {
|
||||
console.error(`${FgRed}It looks like you forgot to run "npm install" before building.${Reset}`);
|
||||
console.error(`"npm install" sets up dependencies required to build the fonts.`);
|
||||
console.error(`Run the following command in your ${shellWord} and retry:`);
|
||||
console.error(` ${FgYellow}npm install${Reset}`);
|
||||
console.error();
|
||||
process.exit(1);
|
||||
}
|
25
verdafile.js
25
verdafile.js
|
@ -2,26 +2,27 @@
|
|||
|
||||
const fs = require("fs");
|
||||
const build = require("verda").create();
|
||||
const which = require("which");
|
||||
const Path = require("path");
|
||||
const toml = require("@iarna/toml");
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
const { task, file, oracle, computed, phony } = build.ruleTypes;
|
||||
const { de, fu, sfu, ofu } = build.rules;
|
||||
const { run, node, cd, cp, rm, mv, fail, echo } = build.actions;
|
||||
const { run, node, cd, cp, rm, mv, fail, echo, silently } = build.actions;
|
||||
const { FileList } = build.predefinedFuncs;
|
||||
const which = require("which");
|
||||
|
||||
module.exports = build;
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
const Path = require("path");
|
||||
const toml = require("@iarna/toml");
|
||||
|
||||
const BUILD = ".build";
|
||||
const DIST = "dist";
|
||||
const SNAPSHOT_TMP = ".build/snapshot";
|
||||
const DIST_SUPER_TTC = "dist/.super-ttc";
|
||||
const ARCHIVE_DIR = "release-archives";
|
||||
|
||||
const TTX = "ttx";
|
||||
const PATEL_C = ["node", "./node_modules/patel/bin/patel-c"];
|
||||
const TTCIZE = ["node", "node_modules/otb-ttc-bundle/bin/otb-ttc-bundle"];
|
||||
const webfontFormats = [
|
||||
|
@ -52,6 +53,14 @@ const Version = oracle(`oracle:version`, async target => {
|
|||
return package_json.version;
|
||||
});
|
||||
|
||||
const CheckTtfAutoHintExists = oracle(`oracle:check-ttfautohint-exists`, async target => {
|
||||
try {
|
||||
return await which("ttfautohint");
|
||||
} catch (e) {
|
||||
fail("External dependency <ttfautohint>, needed for building hinted font, does not exist.");
|
||||
}
|
||||
});
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
////// Plans //////
|
||||
///////////////////////////////////////////////////////////
|
||||
|
@ -309,9 +318,9 @@ const DistUnhintedTTF = file.make(
|
|||
const DistHintedTTF = file.make(
|
||||
(gr, fn) => `${DIST}/${gr}/ttf/${fn}.ttf`,
|
||||
async (target, path, gr, f) => {
|
||||
const [{ hintParams }] = await target.need(FontInfoOf(f));
|
||||
const [{ hintParams }, hint] = await target.need(FontInfoOf(f), CheckTtfAutoHintExists);
|
||||
const [from] = await target.need(BuildTTF(gr, f), de`${path.dir}`);
|
||||
await run("ttfautohint", hintParams, from.full, path.full);
|
||||
await silently.run(hint, hintParams, from.full, path.full);
|
||||
}
|
||||
);
|
||||
const DistWoff2 = file.make(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue