Path: blob/main/core/build/make-dependencies.js
1391 views
const { existsSync, readFileSync, realpathSync } = require("fs");1const { join } = require("path");2const { execSync } = require("child_process");34if (existsSync("package.json")) {5const package = JSON.parse(readFileSync("package.json").toString());67const root = realpathSync(".");89const MAKE_DEP_EXCLUDE = process.env.MAKE_DEP_EXCLUDE ?? "";1011for (const key of ["devDependencies", "dependencies"]) {12for (const name in package[key] ?? {}) {13if (package[key][name].startsWith("workspace:")) {14if (MAKE_DEP_EXCLUDE.includes(`:${name}:`)) {15// Avoid possibility of infinite recursion in case of circular dep.16// I don't think I have any, but sometime it's going to happen.17throw Error(18`CIRCULAR DEPENDENCY: MAKE_DEP_EXCLUDE=${MAKE_DEP_EXCLUDE}, name=${name}`19);20}21if (existsSync(join(root, "node_modules", name, "dist"))) {22// assume it was already built. This isn't meant to be a "always ensure up to date",23// but rather -- build if it obviously wasn't built.24continue;25}26console.log(`\nDEPENDENCY: ${name} - make`);27const cwd = realpathSync(join(root, "node_modules", name));28console.log(`cd '${cwd}'`);29// run make there30execSync("make", {31stdio: "inherit",32cwd,33env: {34...process.env,35MAKE_DEP_EXCLUDE: MAKE_DEP_EXCLUDE + ":" + name + ":",36},37});38console.log(`DEPENDENCY: ${name} successfully built\n`);39console.log(`cd "${root}"`);40}41}42}43}444546