New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

finse

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

finse

A command line tool template

latest
Source
npmnpm
Version
1.5.8
Version published
Maintainers
1
Created
Source

finse

Find which files reference the target file

Features

  • Friendly output
  • Supports alias via tsconfig.json
  • Supports esm and cjs
  • Detect the project root directory
  • Unlimited file types

Install

$ npm i -g finse
$ finse -h # help

Usage

Suppose we have a project, its directory structure is like this:

finse
  └─ test
      └─ demo
          ├─ bar
              ├─ corge
                  └─ nacho.vue
              └─ oop.ts
          ├─ foo
              └─ sharp.js # sdf
          └─ thud.tsx

And you want to find out which files reference oop.ts,just run:

$ finse test/demo/bar/oop.ts

Maybe you will see the output similar to this:

The yellow background represents the file you want to match, the cyan background is the file that "uses" it

API

--root [rootname]

  • Specify the project root directory

--expand

  • Expand collapsed file tree

--link

  • Display the absolute path of the file. That way other files can be accessed directly through the terminal

--ignore

  • Ignore file does not exist errors

Motivation

  • It's hard to find which other files use the target file

  • Search in IDEA is not enough, it's difficult to give exact search keywords

How is works ?

  • First, it will detect the project root directory if no directory is specified
  • By default, the directory where package.json is located is selected as the root directory
  • Next, all reasonable files in the directory will be scanned
  • Then match the contents of the file to see if there is an import statement
  • finse will recognize the following imports
// static import
import xx from 'xxx'

if (Math.random() > 0.5) {
  // dynamic import
  import('xx.ts')
}

// require import
require('./xx/xx')

finse works with regular expressions, But don't worry about "accidental recognition":

// Yes, legal import
import xx from 'xxx'

// No,Imports in comments are not recognized
// comment: import xx from 'xxx'

And supports identifying paths with alias:

<script setup>
import xx from '@/xx'
// or:
import xxx from '~/xx'
</script>

But have to make sure there is such a configuration in [t|j]sconfig.json:

{
  "compilerOptions": {
    "paths": {
      "~/*": ["test/demo/bar/*"],
      "@/*": ["src/*"]
    }
  }
}

finse

it's mean find use

Acknowledgement

Thanks for the proposal for jsconfig.json by Artsmp

Keywords

cli

FAQs

Package last updated on 14 Dec 2022

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