@truffle/compile-solidity
Version:
Compiler helper and artifact manager for Solidity files
37 lines • 1.47 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Cache = void 0;
const config_1 = __importDefault(require("@truffle/config"));
const path_1 = __importDefault(require("path"));
const fs_1 = __importDefault(require("fs"));
class Cache {
constructor() {
const compilersDir = path_1.default.resolve(config_1.default.getTruffleDataDirectory(), "compilers");
const compilerCachePath = path_1.default.resolve(compilersDir, "node_modules"); // because babel binds to require & does weird things
if (!fs_1.default.existsSync(compilersDir))
fs_1.default.mkdirSync(compilersDir);
if (!fs_1.default.existsSync(compilerCachePath))
fs_1.default.mkdirSync(compilerCachePath); // for 5.0.8 users
this.compilerCachePath = compilerCachePath;
}
list() {
return fs_1.default.readdirSync(this.compilerCachePath);
}
add(code, fileName) {
const filePath = this.resolve(fileName);
fs_1.default.writeFileSync(filePath, code);
}
has(fileName) {
const file = this.resolve(fileName);
return fs_1.default.existsSync(file);
}
resolve(fileName) {
return path_1.default.resolve(this.compilerCachePath, fileName);
}
}
exports.Cache = Cache;
;
//# sourceMappingURL=Cache.js.map