Find a file given a declaration of locations.
var fined = require("fined");
fined({ path: "path/to/file", extensions: [".js", ".json"] });
// => { path: '/absolute/path/to/file.js', extension: '.js' } (if file exists)
// => null (if file does not exist)
var opts = {
name: ".app",
cwd: ".",
extensions: {
rc: "default-rc-loader",
".yml": "default-yml-loader",
},
};
fined({ path: "." }, opts);
// => { path: '/absolute/of/cwd/.app.yml', extension: { '.yml': 'default-yml-loader' } }
fined({ path: "~", extensions: { rc: "some-special-rc-loader" } }, opts);
// => { path: '/User/home/.apprc', extension: { 'rc': 'some-special-rc-loader' } }-
pathObj [string | object] : a path setting for finding a file.
-
opts [object] : a plain object supplements
pathObj.pathObjandoptscan have same properties:- path [string] : a path string.
- name [string] : a basename.
- extensions: [string | array | object] : extensions.
- cwd: a base directory of
pathand for finding up. - findUp: [boolean] : a flag to find up.
This function returns a plain object which consists of following properties if a file exists otherwise null.
- path : an absolute path
- extension : a string or a plain object of extension.
No LLMs for issues.
No LLMs for patches / pull requests.
No LLMs for comments on the bug tracker, including translation.
English is encouraged, but not required. You are welcome to post in your native language and rely on others to have their own translation tools of choice to interpret your words.
MIT