intreface.cli
Version:
Intreface Dev Tools
31 lines (30 loc) • 1.23 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateIsIpV4 = exports.validateStringNotEmpty = exports.validateFileExist = exports.validateDirectoryExist = void 0;
const io_1 = require("./io");
const chalk_1 = require("chalk");
const isIp = require("is-ip");
exports.validateDirectoryExist = (input) => {
if (!io_1.isDirectoryExist(input)) {
throw new Error(`${chalk_1.default.red('💩')} directory "${input}" ${chalk_1.default.red.underline('Does Not Exist')}`);
}
return true;
};
exports.validateFileExist = (input) => {
if (!io_1.isFileExist(input)) {
throw new Error(`${chalk_1.default.red('💩')} file "${input}" ${chalk_1.default.red.underline('Does Not Exist')}`);
}
return true;
};
exports.validateStringNotEmpty = (input) => {
if (input.length == 0) {
throw new Error(`${chalk_1.default.red('💩')} string is ${chalk_1.default.red.underline('Empty')}`);
}
return true;
};
exports.validateIsIpV4 = (input) => {
if (!isIp.v4(input)) {
throw new Error(`${chalk_1.default.red('💩')} string "${input}" is ${chalk_1.default.red.underline('Not Valid IP')}`);
}
return true;
};