@ccos/package_maker
Version:
Coocaa WebOS APP Command-Line Tools.
43 lines (37 loc) • 914 B
JavaScript
import fs from 'fs';
function findDir(dirName, path) {
const items = fs.readdirSync(path);
for (const curName of items) {
if (curName == dirName) {
const stats = fs.statSync(curName);
if (stats.isDirectory()) {
return true;
}
}
}
return false;
}
function findFile(fileName, path) {
const items = fs.readdirSync(path);
for (const curName of items) {
if (curName == fileName) {
const stats = fs.statSync(curName);
if (stats.isFile()) {
return true;
}
}
}
return false;
}
function findDirInCurr(dirName) {
return findDir(dirName, '.');
}
function findFileInCurr(fileName) {
return findFile(fileName, '.');
}
export default {
findDir,
findDirInCurr,
findFile,
findFileInCurr,
};