556098ed50
Instead, search for stuff up the directory tree, with the main functionality being to look for `Gulpfile.js` and assume the resulting directory is the root. (Unfortunatley, this is implemented twice, one in `scripts` and another in `src`. It's not possible to use a single implementation for both since that would require assuming a directory structure which this is intended to avoid.) Also, in `scripts/build/projects.js`, abstracdt common exec functionality into a local helper, and use full paths based on the above search instead of assuming relative paths assuming CWD being in the project root.
22 lines
693 B
TypeScript
22 lines
693 B
TypeScript
const { join, resolve, dirname } = require("path");
|
|
const { existsSync } = require("fs");
|
|
|
|
// search directories upward to avoid hard-wired paths based on the
|
|
// build tree (same as src/harness/findUpDir.ts)
|
|
|
|
function findUpFile(name) {
|
|
let dir = __dirname;
|
|
while (true) {
|
|
const fullPath = join(dir, name);
|
|
if (existsSync(fullPath)) return fullPath;
|
|
const up = resolve(dir, "..");
|
|
if (up === dir) return name; // it'll fail anyway
|
|
dir = up;
|
|
}
|
|
}
|
|
exports.findUpFile = findUpFile;
|
|
|
|
const findUpRoot = () =>
|
|
findUpRoot.cached || (findUpRoot.cached = dirname(findUpFile("Gulpfile.js")));
|
|
exports.findUpRoot = findUpRoot;
|