{"id":20906879,"url":"https://github.com/underkoen/bsm","last_synced_at":"2026-02-12T13:20:12.191Z","repository":{"id":176559816,"uuid":"641284150","full_name":"UnderKoen/bsm","owner":"UnderKoen","description":null,"archived":false,"fork":false,"pushed_at":"2025-12-15T09:41:30.000Z","size":460,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-18T09:15:56.538Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/UnderKoen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-05-16T06:49:37.000Z","updated_at":"2025-12-15T09:41:33.000Z","dependencies_parsed_at":"2023-12-21T18:57:42.607Z","dependency_job_id":"8923e803-2cf6-4c3d-a51c-d372747b6841","html_url":"https://github.com/UnderKoen/bsm","commit_stats":null,"previous_names":["underkoen/bsm"],"tags_count":29,"template":false,"template_full_name":null,"purl":"pkg:github/UnderKoen/bsm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UnderKoen%2Fbsm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UnderKoen%2Fbsm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UnderKoen%2Fbsm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UnderKoen%2Fbsm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UnderKoen","download_url":"https://codeload.github.com/UnderKoen/bsm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UnderKoen%2Fbsm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29366769,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T08:51:36.827Z","status":"ssl_error","status_checked_at":"2026-02-12T08:51:26.849Z","response_time":55,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2024-11-18T13:35:38.387Z","updated_at":"2026-02-12T13:20:12.161Z","avatar_url":"https://github.com/UnderKoen.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BSM (Basic Script Manager)\n\n[![npm package][npm-img]][npm-url]\n[![Build Status][build-img]][build-url]\n[![Issues][issues-img]][issues-url]\n[![Semantic Release][semantic-release-img]][semantic-release-url]\n\n[npm-img]: https://img.shields.io/npm/v/@under_koen/bsm\n[npm-url]: https://www.npmjs.com/package/@under_koen/bsm\n[build-img]: https://github.com/UnderKoen/bsm/actions/workflows/release.yml/badge.svg\n[build-url]: https://github.com/UnderKoen/bsm/actions/workflows/release.yml\n[issues-img]: https://img.shields.io/github/issues/UnderKoen/bsm\n[issues-url]: https://github.com/UnderKoen/bsm/issues\n[semantic-release-img]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg\n[semantic-release-url]: https://github.com/semantic-release/semantic-release\n\nBSM is a tool that enhances the functionality of NPM by allowing users to define their scripts in a separate files. This\nmakes it easier to create and manage complex scripts using JavaScript, without cluttering your `package.json` file.\n\n## Getting started\n\n### Installation\n\nInstall BSM as a dev dependency or globally.\n\n```bash\nnpm install --save-dev @under_koen/bsm\n```\n\n```bash\nnpm install -g @under_koen/bsm\n```\n\n### Usage\n\nCreate a `package.scripts.js` or `package.scripts.json` file in the root of your project. This file will contain all of\nyour scripts.\n\nWhen using `package.scripts.js`, you can use the following syntax:\n\n```javascript\nmodule.exports = {\n  scripts: {\n    build: {\n      _default: \"bsm clean ~.* --\",\n      esbuild: \"esbuild ...\",\n    },\n    clean: \"rimraf dist/\",\n    lint: {\n      _default: \"bsm ~.* --\",\n      eslint: \"eslint --ext .ts,.js .\",\n      prettier: \"prettier --check .\",\n    },\n  },\n};\n```\n\nWhen using `package.scripts.json`, you can use the following syntax:\n\n```json\n{\n  \"scripts\": {\n    \"build\": {\n      \"_default\": \"bsm clean ~.*\",\n      \"esbuild\": \"esbuild ...\"\n    },\n    \"clean\": \"rimraf dist/\",\n    \"lint\": {\n      \"_default\": \"bsm ~.*\",\n      \"eslint\": \"eslint --ext .ts,.js .\",\n      \"prettier\": \"prettier --check .\"\n    }\n  }\n}\n```\n\nYou can then run your scripts using the `bsm` command.\n\n```bash\nbsm build\n```\n\n```bash\nbsm lint\n```\n\nYou can also run sub-scripts.\n\n```bash\nbsm lint.eslint\n```\n\n## Features\n\n### Script groups\n\nYou can group scripts by using an object or array.\n\n```javascript\nmodule.exports = {\n  scripts: {\n    example: {\n      test: \"echo test script\",\n      variant: \"echo variant script\",\n      subgroups: {\n        test: \"echo test script\",\n        variant: \"echo variant script\",\n      },\n    },\n  },\n};\n```\n\nIn this example the following scripts are available:\n\n- `bsm example.test`\n- `bsm example.variant`\n- `bsm example.subgroups.test`\n- `bsm example.subgroups.variant`\n\n```javascript\nmodule.exports = {\n  scripts: {\n    example: [\"echo test script\", \"echo variant script\"],\n  },\n};\n```\n\nIn this example the following scripts are available:\n\n- `bsm example` (will run all scripts in the array)\n- `bsm example.0`\n- `bsm example.1`\n\n### Default scripts\n\nYou can define a default script for a group of scripts by using the `_default` key.\n\n```javascript\nmodule.exports = {\n  scripts: {\n    example: {\n      _default: \"echo default script\",\n      variant: \"echo variant script\",\n    },\n  },\n};\n```\n\n`bsm example` will execute the default script, while `bsm example.variant` will execute the variant script.\n\n### Specified scripts\n\nSpecified scripts replace the default script when an condition is met.\n\nThe order of precedence is as follows:\n\n- \\_ci\n- \\_[os]\n- \\_default\n\n#### CI Specified scripts\n\nYou can specify CI specific scripts with `_ci` key.\n\n```javascript\nmodule.exports = {\n  scripts: {\n    example: {\n      _default: \"echo default script\",\n      _ci: \"echo ci script\",\n    },\n  },\n};\n```\n\n`bsm example` will execute the `example._ci` when running on a CI environment. When no CI specific script is found, the\ndefault script will be executed.\n\n#### OS Specified scripts\n\nYou can specify OS specific scripts with `_win32`, `_darwin`, and `_linux` keys.\nAll platforms can be seen [here](https://nodejs.org/api/os.html#os_os_platform).\n\n```javascript\nmodule.exports = {\n  scripts: {\n    example: {\n      _default: \"echo default script\",\n      _win32: \"echo windows script\",\n      _darwin: \"echo macos script\",\n      _linux: \"echo linux script\",\n    },\n  },\n};\n```\n\n`bsm example` will execute the `example._win32` on Windows, `example._darwin` on MacOS, and `example._linux` on Linux.\nWhen no OS specific script is found, the default script will be executed.\n\n#### Chipset Specified scripts\n\nYou can specify OS specific scripts with `_x64`, `_x32`, and `_arm64` keys.\nAll Chipsets can be seen [here](https://nodejs.org/api/os.html#os_os_arch).\n\n```javascript\nmodule.exports = {\n  scripts: {\n    example: {\n      _x64: \"echo 64-bit\",\n      _x32: \"echo 32-bit\",\n      _arm: \"echo ARM\",\n      _arm64: \"echo ARM64\",\n      _default: \"echo Unknown\",\n    },\n  },\n};\n```\n\n`bsm example` will execute the `example._win32` on Windows, `example._darwin` on MacOS, and `example._linux` on Linux.\nWhen no OS specific script is found, the default script will be executed.\n\n### Script arguments\n\nAll arguments passed to the `bsm` command after `--` will be passed to all specified scripts.\n\n```javascript\nmodule.exports = {\n  scripts: {\n    example: \"echo\",\n  },\n};\n```\n\n```bash\nbsm example -- Hello World!\n```\n\nThe above command will execute `echo Hello World!`.\n\n### Relative scripts\n\nYou can run scripts relative to the current script by using the `~` prefix.\n\n```javascript\nmodule.exports = {\n  scripts: {\n    example: {\n      _default: \"bsm ~.variant\",\n      variant: \"echo variant script\",\n    },\n  },\n};\n```\n\n```bash\nbsm example\n```\n\nThe above command will execute `example.variant`.\n\n### All scripts\n\nYou can run all scripts in a group by using a `*`.\nIgnores scripts that start with `_`.\n\n```javascript\nmodule.exports = {\n  scripts: {\n    example: {\n      test: \"echo test script\",\n      variant: \"echo variant script\",\n      _ignore: \"echo ignore script\",\n    },\n  },\n};\n```\n\n```bash\nbsm example.*\n```\n\nThe above command will execute `example.test` and `example.variant`.\n\n### Hooks\n\n#### Pre hooks\n\nYou can run scripts before a script by using `_pre`.\n\n```javascript\nmodule.exports = {\n  scripts: {\n    example: {\n      _pre: \"echo pre script\",\n      _default: \"echo default script\",\n    },\n  },\n};\n```\n\n```bash\nbsm example\n```\n\nThe above command will execute `example._pre` and `example._default`.\n\n#### Post hooks\n\nYou can run scripts after a script by using `_post`.\nDoes not run when a script fails.\n\n```javascript\nmodule.exports = {\n  scripts: {\n    example: {\n      _default: \"echo default script\",\n      _post: \"echo post script\",\n    },\n  },\n};\n```\n\n```bash\nbsm example\n```\n\nThe above command will execute `example._default` and `example._post`.\n\n#### On error hooks\n\nYou can run scripts when a script fails by using `_onError`.\n\n```javascript\nmodule.exports = {\n  scripts: {\n    example: {\n      _default: \"exit 1\",\n      _onError: \"echo error script\",\n    },\n  },\n};\n```\n\n```bash\nbsm example\n```\n\nThe above command will execute `example._default` and `example._onError`.\nThis will also exit with code `1`.\n\n#### Catch hooks\n\nYou can run scripts when a script fails by using `_catch`.\n\n```javascript\nmodule.exports = {\n  scripts: {\n    example: {\n      _default: \"exit 1\",\n      _catch: \"echo catch script\",\n    },\n  },\n};\n```\n\n```bash\nbsm example\n```\n\nThe above command will execute `example._default` and `example._catch`.\n\n#### Finally hooks\n\nYou can run scripts when a script fails by using `_finally`.\n\n```javascript\nmodule.exports = {\n  scripts: {\n    example: {\n      _default: \"echo default script\",\n      error: \"exit 1\",\n      _finally: \"echo finally script\",\n    },\n  },\n};\n```\n\n```bash\nbsm example\n```\n\nThe above command will execute `example._default` and `example._finally`.\n\n```bash\nbsm example.error\n```\n\nThe above command will execute `example.error` and `example._finally`.\nAnd exit with code `1`.\n\n### Functions\n\nYou can use functions in your scripts. This only work in javascript files.\n\n```javascript\nmodule.exports = {\n  scripts: {\n    example: () =\u003e {\n      console.log(\"Hello World!\");\n    },\n  },\n};\n```\n\n```bash\nbsm example\n```\n\nThe above command will execute the function and log `Hello World!`.\n\n#### Async functions\n\nYou can use async functions in your scripts. This only work in javascript files.\n\n```javascript\nimport { setTimeout } from \"timers/promises\";\n\nmodule.exports = {\n  scripts: {\n    example: async () =\u003e {\n      await setTimeout(5000);\n      console.log(\"Hello World!\");\n    },\n  },\n};\n```\n\n```bash\nbsm example\n```\n\nThe above command will execute the function and log `Hello World!` after 5 seconds.\n\n#### Arguments\n\nThe function is passed an array of all arguments passed to the script after `--`.\n\n```javascript\nmodule.exports = {\n  scripts: {\n    example: (args) =\u003e {\n      console.log(args);\n    },\n  },\n};\n```\n\n```bash\nbsm example -- Hello World!\n```\n\nThe above command will execute the function and log `[\"Hello\", \"World!\"]`.\n\n#### Return value\n\nThe function can return scripts, these will handled as if function was not used.\nReturn value can be a string, an array, an object or another function.\n\n```javascript\nmodule.exports = {\n  scripts: {\n    example: () =\u003e {\n      return \"echo Hello World!\";\n    },\n  },\n};\n```\n\n```bash\nbsm example\n```\n\nThe above command will execute `echo Hello World!`.\n\n### Extending\n\nYou can extend scripts by using the `extends` key. You can import scripts from other files or packages.\n\n```javascript\nmodule.exports = {\n  extends: [\"@under_koen/bsm/package.scripts.js\"],\n  scripts: {},\n};\n```\n\n```bash\nbsm lint\n```\n\nThe above command will execute `lint` coming from the `package.scripts.js` of `@under_koen/bsm`.\n\n#### Extending with options (experimental)\n\nYou can extend scripts with options by using the `extends` key. You can import scripts from other files or packages.\n\n```javascript\n// package.scripts.js\nmodule.exports = {\n  extends: [[\"./test\", \"World\"]],\n  scripts: {},\n};\n```\n\n```javascript\n// test.js\n\nmodule.exports = (name) =\u003e ({\n  scripts: {\n    test: `echo Hello ${name}!`,\n  },\n});\n```\n\n```bash\nbsm test\n```\n\nThe above command will execute `echo Hello World!`.\n\n## Trouble shooting\n\n### `Script '/home/runner' not found`\n\nWhen using a unix based OS, you might get the following error:\n\n```bash\nScript '{home}' not found\n```\n\nThis is caused by the `~` prefix being expanded by the shell.\nYou can fix this by using `bsm \\~` instead of `bsm ~`.\nIn version `1.0.1` and above we try to detect this and fix it automatically.\n\n## Future plans\n\n- [ ] Have support for workspaces / lerna\n- [ ] Have support for running scripts in parallel\n- [ ] Jetbrains and VSCode integration\n\n## License\n\nBSM is released under the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funderkoen%2Fbsm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funderkoen%2Fbsm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funderkoen%2Fbsm/lists"}