{"id":23514815,"url":"https://github.com/bguiz/erun","last_synced_at":"2025-11-06T12:03:11.164Z","repository":{"id":57226851,"uuid":"74519112","full_name":"bguiz/erun","owner":"bguiz","description":"Multi-environment aware task runner for NodeJs projects.","archived":false,"fork":false,"pushed_at":"2017-02-05T04:03:38.000Z","size":29,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-04-22T19:57:27.917Z","etag":null,"topics":["multi-environment","npm-scripts","task-runner"],"latest_commit_sha":null,"homepage":"http://blog.bguiz.com/2017/managing-multi-env-nodejs-deployments/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bguiz.png","metadata":{"files":{"readme":"README.asciidoc","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-22T22:32:01.000Z","updated_at":"2017-02-05T02:39:02.000Z","dependencies_parsed_at":"2022-08-24T15:25:21.544Z","dependency_job_id":null,"html_url":"https://github.com/bguiz/erun","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bguiz%2Ferun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bguiz%2Ferun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bguiz%2Ferun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bguiz%2Ferun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bguiz","download_url":"https://codeload.github.com/bguiz/erun/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254029010,"owners_count":22002284,"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":["multi-environment","npm-scripts","task-runner"],"created_at":"2024-12-25T14:10:58.678Z","updated_at":"2025-11-06T12:03:06.125Z","avatar_url":"https://github.com/bguiz.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"= `erun`\n\nMulti-environment aware task runner for NodeJs projects.\n\nimage:https://nodei.co/npm/erun.png[\"NodeJs public registry listing\",link=\"https://github.com/bguiz/erun/\"]\n\nimage:https://travis-ci.org/bguiz/erun.svg?branch=develop[\"Continuous Integration Build Status\",link=\"https://travis-ci.org/bguiz/erun\"]\n\n== Installation\n\n[source,bash]\n----\nnpm install --save-dev erun\n----\n\n== Usage\n\nRun the following on the command line.\n\n[source,bash]\n----\n# Runs myTask with NODE_ENV=localhost\nnpm run erun -- myTask localhost\n\n# Runs myTask with NODE_ENV=dev and with 2 extra arguments\nnpm run erun -- myTask dev argOne argTwo\n\n# Runs myTask with NODE_ENV=production and NODE_SUB_ENV=staging\nnpm run erun -- myTask production-staging\n----\n\nSpecify `envSplitOn` in `erunConfig` if you wish to make use of `NODE_SUB_ENV`.\nThis is optional, but useful when you need to support multiple deployment environments\nwhich utilise the same `NODE_ENV`,\ne.g. `production` might have `live`, `staging`, `pentest`, and `loadtest`.\n\n== Configuration\n\nEdit `package.json`.\n\nFor convenience, create an `npm run` script first:\n\n[source,json]\n----\n{\n\t\"scripts\": {\n\t\t\"erun\": \"erun \"\n\t}\n}\n----\n\nNext add an `erun` hash,\ncontaining one or more `erun` scripts.\n\nEach one needs a `cmd` as a string,\nand optionally may specify `env` as a hash of environment variables.\n\n=== `cmd`\n\n[source,json]\n----\n{\n\t\"erun\": {\n\t\t\"start\": {\n\t\t\t\"cmd\": \"node ./server/run.js\"\n\t\t},\n\t\t\"start localhost\": {\n\t\t\t\"cmd\": \"nodemon --inspect ./server/run.js\",\n\t\t\t\"env\": {\n\t\t\t\t\"DEBUG\": \"true\"\n\t\t\t}\n\t\t}\n\t}\n}\n----\n\nIn the above example, `npm run erun -- start localhost` would be the equivalent of executing\n`DEBUG=true nodemon --inspect ./server/run.js`,\nwhereas `npm run erun -- start dev` (or any environment other than `localhost`) would be the equivalent of executing\n`node ./server/run.js`\n\n=== `env`\n\nOptionally, also edit `package.json` to add `erunConfig`.\n\n[source,json]\n----\n{\n\t\"erunConfig\": {\n\t\t\"envSplitOn\": \"-\"\n\t}\n}\n----\n\n=== Variable substitution\n\nYou can use the `${something}` syntax to substitute environment variables within the `env` hash,\nas well as the `cmd` string.\n\n[source,json]\n----\n{\n\t\"erun\": {\n\t\t\"test\": {\n\t\t\t\"cmd\": \"mocha --reporter mochawesome ./test/${NODE_ENV}-bootstrap.js ./test/**/*.spec.js\",\n\t\t\t\"env\": {\n\t\t\t\t\"MOCHAWESOME_REPORTDIR\": \"./reports/test/${NODE_ENV}\",\n\t\t\t\t\"MOCHAWESOME_REPORTTITLE\": \"Tests on ${NODE_ENV}\"\n\t\t\t}\n\t\t}\n\t}\n}\n----\n\nIn the above example, we see this employed in a `test` task,\nwhere `NODE_ENV` is used within the `env` hash to differ the report file name and title,\nand used within `cmd` to differ the \"bootstrap\" file loaded prior to the \"spec\" files.\n\n=== Differing behaviour per environment\n\n==== Differing `cmd`:\n\nYou can specify a default `erun` command for all environments,\nand also one for some environments or even sub-environments.\n\n[source, json]\n----\n{\n\t\"erun\": {\n\t\t\"start\": {\n\t\t\t\"cmd\": \"node ./server/start.js\"\n\t\t},\n\t\t\"start localhost\": {\n\t\t\t\"cmd\": \"nodemon --inspect ./server/start.js\"\n\t\t}\n\t}\n}\n----\n\nIn the above example, `erun start dev` or `erun start production`\nwould run the server script via `node`,\nbut only `erun start localhost`\nwould run the server script via `nodemon`.\n\n==== Differing `env`:\n\nIf you would like the `cmd` to be the same on a particular environment,\nbut have different environment variables, you can do that too.\n\n[source, json]\n----\n{\n\t\"erun\": {\n\t\t\"start\": {\n\t\t\t\"cmd\": \"node ./server/start.js\"\n\t\t},\n\t\t\"start localhost\": {\n\t\t\t\"env\": {\n\t\t\t\t\"DEBUG\": \"true\"\n\t\t\t}\n\t\t}\n\t}\n}\n----\n\nIn the above example,\n`erun start localhost`, `erun start dev`, and `erun start production`\nwould all run the server script via `node`,\nbut only `erun start localhost`\nwould do so with the `DEBUG` environment variable set.\n\n==== Differing both `cmd` and `env`\n\nShould you wish to do this, simply set *both* `cmd` and `env`,\nas shown above,\nand the environment specific `erun` script will not\ncopy any behaviour from the generic `erun` script of the same name.\n\n== Licence\n\nGPLv3\n\n== Author\n\nhttp://bguiz.com[Brendan Graetz]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbguiz%2Ferun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbguiz%2Ferun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbguiz%2Ferun/lists"}