npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

uni-run

v1.1.20

Published

Universal Runner for many language

Downloads

176

Readme

uni-run

uni-run is a versatile CLI tool designed to run various types of scripts, including but not limited to JavaScript, TypeScript, Python, Java, HTML, SASS, Lua, and more. It provides a unified interface to execute scripts with additional features like watching for file changes, benchmarking execution time, and more.

Features

  • Watch Mode: Automatically re-run scripts when files change.
  • Benchmarking: Measure and display the execution time of scripts.
  • Environment Variables: Set environment variables for script execution.
  • Shell Execution: Run scripts in a shell for more control.
  • Console Clearing: Clear the console before running the script.
  • Reload Key: Enable reloading the script with a specific key combination.
  • Information Display: Show detailed information about the script execution.

Installation

To install uni-run, use npm:

npm install -g uni-run

CLI Usage

Basic Command

To run a script, use the following command:

run script.ext [options] -- [args for internal bin]
uni-run script.ext [options] -- [args for internal bin]

Examples

Running a JavaScript File

run ./scripts/main.js

Running a TypeScript File

run ./scripts/main.ts

Running a Python File

run ./scripts/main.py

Running a Java File

run ./scripts/Main.java

Running with script argv

run ./scripts/main.js -- --some someValue

Here --some someValue will be passed to node and will be ignored by uni-run.

Define Custom Configuration

Create .uni-run.json file in your user home directory or current working directory.

{
  "javascript-runtime": "bun",
  "typescript-runtime": "deno"
}

Now you can run your script with run script.js or run script.ts with your own runtime.

Setup Custom Executors

Create .uni-run.cjs file in your user home directory or current working directory. NOTE: Your custom executors will have more priority than the default executors.

module.exports = [
  {
    name: 'Name',
    exts: ['ext'],
    getRuntime(args, options, config) {
      return {
        exec: ['YOUR_BIN', ...args],
      }
    },
  },
]

Now you can run your script with run script.ext.

API

The uni-run package provides a simple API to manage and execute scripts.

addExecutorBefore(options: ExecutorOptions) or addExecutorAfter(options: ExecutorOptions):

Both methods add an executor to the list of executors. The addExecutorBefore method adds the executor before the default executors, while the addExecutorAfter method adds the executor after the default executors. This means that the executor will be used before or after checking the default executors.

import uniRun from 'uni-run'

uniRun.addExecutorBefore({
  name: 'Name',
  exts: ['ext'],
  getRuntime(args, options, config) {
    return {
      exec: ['YOUR_BIN', ...args],
    }
  },
})

start(args?: string[]):

Starts the application with the provided arguments.

import uniRun from 'uni-run'

uniRun.start(['arg1', 'arg2'])

Example Usage

import uniRun from 'uni-run'

// Add the Executor to uni-run
uniRun.addExecutorBefore({
  name: 'Name',
  exts: ['ext'],
  getRuntime(args, options, config) {
    return {
      exec: ['YOUR_BIN', ...args],
    }
  },
})

// Start the application with arguments
uniRun.start(['arg1.some'])

// Or inherit from CLI
uniRun.start()