All Projects → benoror → Better Npm Run

benoror / Better Npm Run

Licence: mit
🏃‍♂️ Better NPM scripts runner

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Better Npm Run

Npm Run All
A CLI tool to run multiple npm-scripts in parallel or sequential.
Stars: ✭ 4,496 (+608.03%)
Mutual labels:  npm-scripts, cli-command, npm
Redrun
✨🐌 🐎✨ fastest npm scripts runner
Stars: ✭ 85 (-86.61%)
Mutual labels:  npm-scripts, cli-command, npm
Yarpm
CLI tool to run npm scripts with either npm or yarn, depending on how it was started
Stars: ✭ 13 (-97.95%)
Mutual labels:  npm-scripts, npm
Npm Script Naming Ideas
Ideas for naming npm scripts
Stars: ✭ 12 (-98.11%)
Mutual labels:  npm-scripts, npm
Nls
Missing inspector for npm packages.
Stars: ✭ 44 (-93.07%)
Mutual labels:  npm-scripts, npm
Awesome Node Utils
some useful npm packages for nodejs itself
Stars: ✭ 51 (-91.97%)
Mutual labels:  npm-scripts, npm
Ultra Runner
🏃⛰ Ultra fast monorepo script runner and build tool
Stars: ✭ 496 (-21.89%)
Mutual labels:  npm-scripts, npm
Nps
NPM Package Scripts -- All the benefits of npm scripts without the cost of a bloated package.json and limits of json
Stars: ✭ 1,285 (+102.36%)
Mutual labels:  npm-scripts, npm
Postinstall Build
Helper for conditionally building your npm package on postinstall
Stars: ✭ 87 (-86.3%)
Mutual labels:  npm-scripts, npm
Npm Run
Run locally-installed node module executables.
Stars: ✭ 180 (-71.65%)
Mutual labels:  npm-scripts, npm
Cpx
A cli tool to watch and copy file globs.
Stars: ✭ 394 (-37.95%)
Mutual labels:  cli-command, npm
Ram
⚛️ React Application Manager: create and run React (and other) applications – no command line or build setup required
Stars: ✭ 585 (-7.87%)
Mutual labels:  npm
Npq
🎖safely* install packages with npm or yarn by auditing them as part of your install process
Stars: ✭ 513 (-19.21%)
Mutual labels:  npm
Synp
Convert yarn.lock to package-lock.json and vice versa
Stars: ✭ 510 (-19.69%)
Mutual labels:  npm
Bower Material
This repository is used for publishing the AngularJS Material v1.x library
Stars: ✭ 510 (-19.69%)
Mutual labels:  npm
Articles Translator
📚Translate the distinct technical blogs. Please star or watch. Welcome to join me.
Stars: ✭ 606 (-4.57%)
Mutual labels:  npm
Eslint Plugin React Native
React Native plugin for ESLint
Stars: ✭ 580 (-8.66%)
Mutual labels:  npm
Request Ip
A Node.js module for retrieving a request's IP address on the server.
Stars: ✭ 501 (-21.1%)
Mutual labels:  npm
Migrate Mongo
A database migration tool for MongoDB in Node
Stars: ✭ 481 (-24.25%)
Mutual labels:  npm
New Bee
开源社区 vue + springBoot - 前后分离微服务的最佳实践
Stars: ✭ 619 (-2.52%)
Mutual labels:  npm

⚠️ ‼️ DEPRECATION WARNING ‼️ ⚠️

This solution is outdated. Check out kentcdodds/cross-env which might better suit your needs!


NPM

Join the chat at https://gitter.im/benoror/better-npm-run

Build Status

PRs Welcome

8dfc4b1170a25e07c254c99f6f549caf

Better NPM scripts runner

Inspired by

Alternatives

Usage in package.json

From this:

{
  "scripts": {
    "build:dist": "NODE_ENV=development webpack --config $npm_package_webpack --progress --colors",
    "test": "NODE_ENV=production karma start"
  }
}

To this:

{
  "devDependencies": {
    "better-npm-run": "~0.0.1"
  },
  "scripts": {
    "build:dist": "better-npm-run build:dist",
    "build:prod": "better-npm-run build:prod",
    "test": "better-npm-run test"
  },
  "betterScripts": {
    "build:dist": "webpack --config $npm_package_webpack --progress --colors",
    "build:prod": {
      "command": "webpack --config $npm_package_webpack --progress --colors",
      "env": {
        "NODE_ENV": "production"
      }
    },
    "test": {
      "command": "karma start",
      "env": {
        "NODE_ENV": "test"
      }
    }
  }
}

The betterScripts script definition can either be a string or sub-object with command and env attributes. Values defined in the env block will override previously set environment variables.

Note that depending on the OS and terminal you're using, dots, spaces or other special characters in the command path may be treated as separators and the command will be parsed wrong.

{
  "serve:dist": "./node_modules/.bin/webpack-dev-server --hot --inline --config webpack/development.js"
}

To prevent this you need to explicitly wrap the command path with double quotes:

{
  "serve:dist": "\"./node_modules/.bin/webpack-dev-server\" --hot --inline --config webpack/development.js"
}

.env File

If you have an .env file in your project root it will be loaded on every command.

NODE_PATH=./:./lib
NODE_ENV=development
PORT=5000

Environment variables defined in the betterScripts script definition will take precedence over .env values.

Shell scripts

Currently, using bash variables (PWD, USER, etc.) is not possible:

  "command": "forever start -l ${PWD}/logs/forever.log -o ${PWD}/logs/out.log -e ${PWD}/logs/errors.log -a index.js",

In order to use them, you can create an script file (.sh) instead:

forever.sh:

forever start -l ${PWD}/logs/forever.log -o ${PWD}/logs/out.log -e ${PWD}/logs/errors.log -a index.js

package.json:

  "command": "./forever.sh"

cli commands

This module expose 2 cli commands:

  • better-npm-run and,
  • a shorter one: bnr which is an alias to the former.

The shorter one is useful for cases where you have a script that calls several better-npm-run scripts. e.g:

using the normal cli name

"scripts": {
  "dev": "shell-exec 'better-npm-run install-hooks' 'better-npm-run watch-client' 'better-npm-run start-dev' 'better-npm-run start-dev-api' 'better-npm-run start-dev-worker' 'better-npm-run start-dev-socket'",
}

using the shorter alias

"scripts": {
  "dev": "shell-exec 'bnr install-hooks' 'bnr watch-client' 'bnr start-dev' 'bnr start-dev-api' 'bnr start-dev-worker' 'bnr start-dev-socket'",
}

And for silence output, you can use -s or verbose --silence flags

bnr -s watch-client

And you can use -p or verbose --path to specify a custom path of dotenv file

bnr --path=/custom/path/to/your/env/vars start-dev

Also use -e or verbose --encoding to specify the encoding of dotenv file

bnr --encoding=base64 start-dev

See envdot docs for more infomation

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].