Releasing < validate-access > Validate project accessibility files
source link: https://github.com/jalal246/validate-access
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
validate-access
Validate project accessibility files
npm install validate-access
API
validateAccess
/** * Validates access for `package.json` and project entry if * provided. * * @param {string} [dir="."] - project directory * @param {boolean} [isValidateEntry=false] - if false, it only validate `package.json` * @param {string} [entry="index"] * @param {string} [srcName="src"] * * @returns {Object} result * @returns {boolean} result.isValid - true, if access is valid * @returns {boolean} result.isSrc - true, if project contains src folder * @returns {string} result.ext - entry file extension */ function validateAccess({ dir, isValidateEntry, entry, srcName })
Example(1)
import { validateAccess } from "validate-access"; const { isValid, isSrc, ext } = validateAccess({ dir: "path/to/valid", isValidateEntry: true }); // { isValid: true, isSrc: true, ext: js }
getFileExtension
getFileExtension
is used internally by validateAccess
however it is exported
for further use.
/** * Gets extension used in for given entry * * @param {string} dir - project directory * @param {string} entry - project file entry name * @returns {string|undefined} extension if exist */ function getFileExtension(dir, entry)
Example(2)
import { validateAccess } from "validate-access"; const extension = getFileExtension("path/to/valid", "index"); // extension > js
Related projects
-
packageSorter - Sorting packages for monorepos production.
-
builderz - Build your project(s) with zero configuration
-
corename - Extracts package name.
-
move-position - Moves element index in an array.
-
get-info - Utility functions for projects production.
-
textics & textics-stream - Counts lines, words, chars and spaces for a given string.
Test
npm test
License
This project is licensed under the GPL-3.0 License
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK