Socket
Book a DemoInstallSign in
Socket

urequ

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

urequ

Command line tool for finding correct require paths

1.0.6
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

urequ

A simple cli command to know WTF is the correct path to be required when we have a complex project.

Install

npm install -g urequ

Usage

urequ requirer required

Find a library path

For example, imagine that inside

/Users/sullof/Projects/qabra/web/src/server/controller/jokes.es6

we want to require the library

/Users/sullof/Projects/qabra/common/lib/remote/funny.js

and we are in a terminal window at

/Users/sullof/Projects/qabra/web

Using the shell autocomplete we can easily execute

urequ src/server/controller/jokes.es6 ../common/lib/remote/funny.js

which will return

const funny = require('../../../../../common/lib/remote/funny')

If the requiring file is not a javascript file the result is a bit different. For example:

urequ src/server/controller/jokes.es6 src/server/data.json

will return

const dataJson = require('../data.json')

Inject a require statement

If you like, you can inject the line at the top of the requirer, specifying the name of the constant. For example:

urequ src/server/controller/jokes.es6 src/server/data.json Data

will inject at the top of jokes.es6 the line

const Data = require('../data.json')

If there is a statement 'use strict' the like is inserted after it. And, of course, after inserting it, you can move it where you like : )

MIT Licence

Version 1.0.0 — 02/25/2016

(c) Francesco Sullo sullof@gmail.com

FAQs

Package last updated on 06 Dec 2018

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.