@slippy-lint/slippy
Version:
A simple but powerful linter for Solidity
42 lines (41 loc) • 1.23 kB
JavaScript
/*
This file includes code taken from the Hardhat project:
https://github.com/NomicFoundation/hardhat/blob/7e228d09ad28dd7206be6571fb16a29927f2d693/v-next/hardhat-utils/src/fs.ts
The original code is licensed under the MIT License:
https://github.com/NomicFoundation/hardhat/blob/7e228d09ad28dd7206be6571fb16a29927f2d693/v-next/hardhat-utils/LICENSE
*/
import path from "node:path";
import fs from "node:fs/promises";
export async function findUp(fileName, from) {
let currentDir = from;
while (true) {
const absolutePath = path.join(currentDir, fileName);
if (await exists(absolutePath)) {
return absolutePath;
}
const parentDir = path.dirname(currentDir);
if (parentDir === currentDir) {
return undefined;
}
currentDir = parentDir;
}
}
export async function exists(absolutePath) {
try {
await fs.access(absolutePath);
return true;
}
catch {
return false;
}
}
export async function isDirectory(absolutePath) {
try {
const stats = await fs.stat(absolutePath);
return stats.isDirectory();
}
catch {
return false;
}
}
//# sourceMappingURL=fs.js.map