🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

file-getter

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

file-getter

向上查找,获取文件对应路径。

latest
npmnpm
Version
0.0.2
Version published
Weekly downloads
5
150%
Maintainers
1
Weekly downloads
 
Created
Source

file-getter

向上查找,获取文件对应路径。

获取使用的npm包所在路径。

Get the file path of the filename or the npm package.

特性(Features)

  • 只依赖 fs 模块;
  • 只依赖 path 模块。

安装(Installation)

npm install file-getter
yarn add file-getter
pnpm add file-getter

使用(Usage)

引入

import { file_getter, get_pkg_path } from 'file-getter';

file_getter('test.js');
//=>./test.js

file_getter('test2.js');
//=> /xxx/test2.js

get_pkg_path('vue');
//=> xxx/node_modules/vue/package.json


配置文件查找路径

import { file_getter } from 'file-getter';

// 查找上级目录中,是否有 ./src/test.js 文件
file_getter('test.js', {
  relativeFileDir: 'src'
});
//=> /user/test/src/test.js


查找包所在路径

import { file_getter } from 'file-getter';

// 查找上级目录中,是否有 ./src/test.js 文件
file_getter('test.js', {
  searchPath: 'src'
});
//=> /user/test/src/test.js

FAQs

Package last updated on 04 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts