🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

rrun

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

rrun

Require and run a js file with one command

latest
Source
npmnpm
Version
1.0.5
Version published
Maintainers
1
Created
Source

rrun

This is a small utility to require and run modules from the command line.

Install

npm i -D rrun

Usage

Command Line:

$ rrun path/to/some-module [arguments ...]

rrun will require a file and run it's default export with any arguments passed along. It can be useful for running development tasks. This way, tasks can be run directly from npm scripts or the command line, but they can also be required and run from other task files. It's not intended to run anything other than basic node modules that export a single function.

Example Task Setup:

Assume we have a task to compile sass and we want to run it from npm scripts and also from our watch task.

// sass-task.js

module.exports = () => {
  // do sassy stuff
};

You can use it in your watch task:

const chokidar = require('chokidar');
const sass = require('path/to/sass-task');

chokidar.watch('./src/scss/**/*.scss').on('change', sass);

And you can rrun it from your npm scripts:

"scripts": {
  "sass": "rrun path/to/sass-task"
}

PSA: You can do the same thing without using rrun:

"scripts": {
  "any-task": "node -e \"require('path/to/module')()\""
}

But ☝️ that is kind of ugly and co-workers may find it confusing.

Keywords

npm

FAQs

Package last updated on 07 Oct 2017

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