UNPKG

container.ts

Version:
46 lines 1.82 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var fs_1 = require("fs"); var path_1 = require("path"); var validate_1 = require("../../validate"); var validate_2 = require("../validate"); /** Validate that value is a valid path to a directory. */ function isDirectory(value) { if (value === void 0) { value = ""; } try { var resolveValue = path_1.resolve(value); if (fs_1.lstatSync(resolveValue).isDirectory() !== true) { throw new validate_2.NodeValidateError(validate_2.ENodeValidateError.IsDirectoryError, value); } return resolveValue; } catch (error) { throw new validate_2.NodeValidateError(validate_2.ENodeValidateError.IsDirectoryError, value, error); } } exports.isDirectory = isDirectory; var DirectoryField = /** @class */ (function (_super) { __extends(DirectoryField, _super); function DirectoryField() { return _super !== null && _super.apply(this, arguments) || this; } DirectoryField.prototype.validate = function (value) { return isDirectory(value); }; return DirectoryField; }(validate_1.Field)); exports.DirectoryField = DirectoryField; //# sourceMappingURL=is-directory.js.map