UNPKG

@nomiclabs/buidler

Version:

Buidler is an extensible developer tool that helps smart contract developers increase productivity by reliably bringing together the tools they want.

39 lines 1.4 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const find_up_1 = __importDefault(require("find-up")); const fs_extra_1 = __importDefault(require("fs-extra")); const path_1 = __importDefault(require("path")); async function getPackageJsonPath() { return findClosestPackageJson(__filename); } async function getPackageRoot() { const packageJsonPath = await getPackageJsonPath(); return path_1.default.dirname(packageJsonPath); } exports.getPackageRoot = getPackageRoot; function findClosestPackageJson(file) { return find_up_1.default.sync("package.json", { cwd: path_1.default.dirname(file) }); } async function getPackageJson() { const root = await getPackageRoot(); return fs_extra_1.default.readJSON(path_1.default.join(root, "package.json")); } exports.getPackageJson = getPackageJson; function getBuidlerVersion() { const packageJsonPath = findClosestPackageJson(__filename); if (packageJsonPath === null) { return null; } try { const packageJson = fs_extra_1.default.readJsonSync(packageJsonPath); return packageJson.version; } catch (e) { return null; } } exports.getBuidlerVersion = getBuidlerVersion; //# sourceMappingURL=packageInfo.js.map