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

hawthorn

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hawthorn

Statically parse dependency trees of JavaScript and TypeScript projects

latest
Source
npmnpm
Version
1.2.7
Version published
Weekly downloads
361
375%
Maintainers
1
Weekly downloads
 
Created
Source

Hawthorn

Statically parse dependency trees of JavaScript and TypeScript projects.

Build Status npm version Dependency Status

Supports CommonJS and ES6 imports, and TSX.

Description

hawthorn is a static analyzer that can build a dependency tree data structure out of a JavaScript or TypeScript project by recursively parsing and scanning for require() calls and import expressions.

Installation

The easiest way to use hawthorn is with its example CLI that you can install with:

npm install --global hawthorn

The CLI takes a --directory/-d option which is the base directory of the project you want to scan, and one or more glob patterns to use as entry points (defaults to lib/**/*.js).

You can test hawthorn on itself by running:

$ git clone https://github.com/jviotti/hawthorn.git
$ hawthorn --directory ./hawthorn 'lib/*.js' > tree.json

See an example of the generated output here: https://github.com/jviotti/hawthorn/blob/master/example.json.

Documentation

If you install hawthorn as a dependency, you can require('hawthorn') and the module will export a top level function that takes an array of path globs, an options object, and resolves a JavaScript object with the resulting dependency tree.

hawthorn(String[] paths, Object options) -> Object

The available options are:

  • directory: The base directory to use when scanning. Should be usually set to the root directory of the project you want to scan
  • types: The types of dependencies to consider. Defaults to [ 'module', 'local', 'internal' ]

Example:

const hawthorn = require('hawthorn')
const tree = hawthorn([
  'lib/**/*.js'
], {
  directory: '~/projects/hawthorn'
})

Support

If you're having any problem, please raise an issue on GitHub and I'll be happy to help.

Tests

Run the test suite by doing:

npm test

Contribute

Before submitting a PR, please make sure that you include tests, and that the linter runs without any warning

License

The project is licensed under the Apache 2.0 license.

FAQs

Package last updated on 29 Jan 2021

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