{"id":13758234,"url":"https://github.com/benoror/better-npm-run","last_synced_at":"2025-05-15T13:06:28.614Z","repository":{"id":57780494,"uuid":"37486254","full_name":"benoror/better-npm-run","owner":"benoror","description":"🏃‍♂️ Better NPM scripts runner","archived":false,"fork":false,"pushed_at":"2022-08-22T07:48:19.000Z","size":51,"stargazers_count":637,"open_issues_count":3,"forks_count":56,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-12T23:11:51.334Z","etag":null,"topics":["cli-command","node","npm","npm-scripts","script-runner"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benoror.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-15T19:23:34.000Z","updated_at":"2025-04-02T07:33:02.000Z","dependencies_parsed_at":"2022-08-28T03:11:26.067Z","dependency_job_id":null,"html_url":"https://github.com/benoror/better-npm-run","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoror%2Fbetter-npm-run","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoror%2Fbetter-npm-run/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoror%2Fbetter-npm-run/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoror%2Fbetter-npm-run/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benoror","download_url":"https://codeload.github.com/benoror/better-npm-run/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254346624,"owners_count":22055808,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli-command","node","npm","npm-scripts","script-runner"],"created_at":"2024-08-03T13:00:21.201Z","updated_at":"2025-05-15T13:06:28.583Z","avatar_url":"https://github.com/benoror.png","language":"JavaScript","funding_links":[],"categories":["NPM Script Commands"],"sub_categories":[],"readme":"# ⚠️ ‼️ DEPRECATION WARNING ‼️ ⚠️\n\nThis solution is outdated. Check out [kentcdodds/cross-env](https://github.com/kentcdodds/cross-env) which might better suit your needs!\n\n---\n\n[![NPM](https://nodei.co/npm/better-npm-run.png)](https://npmjs.org/package/better-npm-run)\n\n[![Join the chat at https://gitter.im/benoror/better-npm-run](https://badges.gitter.im/benoror/better-npm-run.svg)](https://gitter.im/benoror/better-npm-run?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n[![Build Status](https://semaphoreci.com/api/v1/benoror/better-npm-run/branches/master/badge.svg)](https://semaphoreci.com/benoror/better-npm-run)\n\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)\n\n![8dfc4b1170a25e07c254c99f6f549caf](https://user-images.githubusercontent.com/119117/33388438-9c08ff52-d4f5-11e7-87dc-cdcb085a907f.png)\n\nBetter NPM scripts runner\n\n- Avoid hard-coded commands in package.json\n- Cross-platform compatibility, originally needed by:\n    - https://github.com/formly-js/angular-formly/issues/305\n        - https://github.com/npm/npm/issues/2800\n\n# Inspired by\n\n- https://www.npmjs.com/package/with-package\n\n# Alternatives\n\n- [argv-set-env](https://github.com/kentcdodds/argv-set-env)\n- [cross-env](https://github.com/kentcdodds/cross-env)\n\n# Usage in package.json\n\nFrom this:\n```JSON\n{\n  \"scripts\": {\n    \"build:dist\": \"NODE_ENV=development webpack --config $npm_package_webpack --progress --colors\",\n    \"test\": \"NODE_ENV=production karma start\"\n  }\n}\n```\n\nTo this:\n```JSON\n{\n  \"devDependencies\": {\n    \"better-npm-run\": \"~0.0.1\"\n  },\n  \"scripts\": {\n    \"build:dist\": \"better-npm-run build:dist\",\n    \"build:prod\": \"better-npm-run build:prod\",\n    \"test\": \"better-npm-run test\"\n  },\n  \"betterScripts\": {\n    \"build:dist\": \"webpack --config $npm_package_webpack --progress --colors\",\n    \"build:prod\": {\n      \"command\": \"webpack --config $npm_package_webpack --progress --colors\",\n      \"env\": {\n        \"NODE_ENV\": \"production\"\n      }\n    },\n    \"test\": {\n      \"command\": \"karma start\",\n      \"env\": {\n        \"NODE_ENV\": \"test\"\n      }\n    }\n  }\n}\n```\n\n_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._\n\nNote 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.\n\n```JSON\n{\n  \"serve:dist\": \"./node_modules/.bin/webpack-dev-server --hot --inline --config webpack/development.js\"\n}\n```\n\nTo prevent this you need to explicitly wrap the command path with double quotes:\n\n```JSON\n{\n  \"serve:dist\": \"\\\"./node_modules/.bin/webpack-dev-server\\\" --hot --inline --config webpack/development.js\"\n}\n```\n\n# .env File\n\nIf you have an `.env` file in your project root it will be loaded on every command.\n\n```\nNODE_PATH=./:./lib\nNODE_ENV=development\nPORT=5000\n```\n\n_Environment variables defined in the `betterScripts` script definition will take precedence over `.env` values._\n\n# Shell scripts\n\nCurrently, using [bash variables](http://tldp.org/LDP/abs/html/internalvariables.html) (PWD, USER, etc.) is not possible:\n\n``` JSON\n  \"command\": \"forever start -l ${PWD}/logs/forever.log -o ${PWD}/logs/out.log -e ${PWD}/logs/errors.log -a index.js\",\n```\n\nIn order to use them, you can create an script file (`.sh`) instead:\n\n`forever.sh`:\n``` bash\nforever start -l ${PWD}/logs/forever.log -o ${PWD}/logs/out.log -e ${PWD}/logs/errors.log -a index.js\n```\n\n`package.json`:\n``` javascript\n  \"command\": \"./forever.sh\"\n```\n\n## cli commands\n\nThis module expose 2 cli commands:\n- `better-npm-run` and,\n- a shorter one: `bnr` which is an alias to the former.\n\nThe shorter one is useful for cases where you have a script that calls several `better-npm-run` scripts. e.g:\n\nusing the normal cli name\n\n```javascript\n\"scripts\": {\n  \"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'\",\n}\n```\n\nusing the shorter alias\n\n```javascript\n\"scripts\": {\n  \"dev\": \"shell-exec 'bnr install-hooks' 'bnr watch-client' 'bnr start-dev' 'bnr start-dev-api' 'bnr start-dev-worker' 'bnr start-dev-socket'\",\n}\n```\n\nAnd for silence output, you can use `-s` or verbose `--silence` flags\n\n```\nbnr -s watch-client\n```\n\nAnd you can use `-p` or verbose `--path` to specify a custom path of dotenv file\n\n```\nbnr --path=/custom/path/to/your/env/vars start-dev\n```\n\nAlso use `-e` or verbose `--encoding` to specify the encoding of dotenv file\n\n```\nbnr --encoding=base64 start-dev\n```\n\nSee [envdot docs](https://github.com/motdotla/dotenv) for more infomation\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenoror%2Fbetter-npm-run","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenoror%2Fbetter-npm-run","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenoror%2Fbetter-npm-run/lists"}