Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | 2x 2x 2x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x | import fs from "fs-extra";
import rimraf from "rimraf";
import { promisify } from "util";
import { buildToolsRoot } from "consts";
import copy from "lib/helpers/fsCopy";
const rmdir = promisify(rimraf);
let firstBuild = true;
const ensureBuildTools = async (tmpPath: string) => {
const buildToolsPath = `${buildToolsRoot}/${process.platform}-${process.arch}`;
const expectedBuildToolsVersionPath = `${buildToolsPath}/tools_version`;
const expectedToolsVersion = await fs.readFile(
expectedBuildToolsVersionPath,
"utf8",
);
const tmpBuildToolsPath = `${tmpPath}/_gbstools`;
const tmpBuildToolsVersionPath = `${tmpPath}/_gbstools/tools_version`;
if (firstBuild) {
await rmdir(tmpBuildToolsPath);
await copy(buildToolsPath, tmpBuildToolsPath, {
overwrite: true,
mode: 0o755,
});
firstBuild = false;
} else E{
try {
const toolsVersion = await fs.readFile(tmpBuildToolsVersionPath, "utf8");
Iif (toolsVersion !== expectedToolsVersion) {
throw new Error("Incorrect tools version found");
}
} catch (e) {
await rmdir(tmpBuildToolsPath);
await copy(buildToolsPath, tmpBuildToolsPath, {
overwrite: false,
mode: 0o755,
});
}
}
return tmpBuildToolsPath;
};
export default ensureBuildTools;
|