{"id":15286257,"url":"https://github.com/pygy/gosub","last_synced_at":"2025-04-13T03:09:20.850Z","repository":{"id":57252562,"uuid":"110046024","full_name":"pygy/gosub","owner":"pygy","description":"Run pkg.scripts subtasks in a runner-agnostic way (npm/yarn, whichever launched the main script)","archived":false,"fork":false,"pushed_at":"2023-12-25T15:11:09.000Z","size":4,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T03:08:59.887Z","etag":null,"topics":["npm","npm-scripts","subtask","yarn"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pygy.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2017-11-09T00:19:42.000Z","updated_at":"2024-07-13T05:04:52.000Z","dependencies_parsed_at":"2024-09-30T15:12:37.785Z","dependency_job_id":"13ac8a73-ed9e-4ac6-9ba4-d9cb4cacedba","html_url":"https://github.com/pygy/gosub","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pygy%2Fgosub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pygy%2Fgosub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pygy%2Fgosub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pygy%2Fgosub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pygy","download_url":"https://codeload.github.com/pygy/gosub/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248657918,"owners_count":21140846,"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":["npm","npm-scripts","subtask","yarn"],"created_at":"2024-09-30T15:11:32.357Z","updated_at":"2025-04-13T03:09:20.822Z","avatar_url":"https://github.com/pygy.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gosub\n\nYou want to use pkg.scripts subtasks, but you don't want to commit to either `npm run` or `yarn run`? Look no further.\n\nGiven the following `package.json`\n\n```JSON\n{\n  \"name\": \"my-package\",\n  \"version\": \"1.0.0\",\n  \"license\": \"MIT\",\n  \"scripts\": {\n    \"task\": \"gosub subtask \u0026\u0026 gosub print done\",\n    \"subtask\": \"echo ====\u003e\u003e unix: $npm_config_user_agent win: %npm_config_user_agent% \u003c\u003c====\",\n    \"print\":\"echo\"\n  },\n  \"devDependencies\": {\n    \"gosub\": \"1.0.0\"\n  }\n}\n```\n\nAfter running `npm install` or `yarn` you get the following:\n\n```BASH\n~/tmp ❯❯❯ yarn run --silent task\n$ echo \"====\u003e\u003e $npm_config_user_agent \u003c\u003c====\"\n====\u003e\u003e yarn/1.3.2 npm/? node/v8.9.1 darwin x64 \u003c\u003c====\n$ echo done\ndone\n```\n\nand\n\n```BASH\n~/tmp ❯❯❯ npm run --silent task\n====\u003e\u003e npm/5.5.1 node/v8.9.1 darwin x64 \u003c\u003c====\ndone\n```\n\nIn other words, if the main task is launched with `npm run` the sub tasks will be as well. If you launched it with `yarn run`, so will the subtasks (look between the `===\u003e\u003e` arrows `\u003c\u003c====` ).\n\nThis makes your `pkg.scripts` runner agnostic.\n\n## What about other commands beyond `run`?\n\nYou can use `gosub --raw action`. So `gosub --raw install` will run `npm install` (re. `bun`, `yarn`, etc...).\n\n## Why not use `$_ run subtask`?\n\nIt doesn't work on Windows (although it will save you tens if not hundreds of milliseconds on *nix). If it turns out there's a native, cross-platform method to achieve what `gosub` does please chime in in the issues.\n\n## Caveat\n\nThe script works for my own use, but I'm not used to writing command line utilities and may have botched up some details that matter for your use case. For example, this has only been tested on MacOS, althought AFAICT there's nothing OS specific in the script. Feel free to open an issue if you have problems and/or suggestions.\n\n## Is `gosub` a BASIC thing?\n\n\\*Waves at all of you who learned to code on 8/16 bits computers\\*.\n\n## History\n\n### v2.0.0\n\n- Add a `--raw` option to launch other commands `gosub --raw install` will launch `npm install` (or `bun`, `yarn` depending on what you're using) .\n\n### v1.1.0\n\n- Use `child_process.spawn` instead of `.exec` to prevent the parent from exiting early.\n- Have the child inherit the `stdio` streams rather than piping them manually.\n- Also pipe `stdin` to the children processes.\n\n### v1.0.0\n\ninitial release\n\n## License?\n\nRomantic WTF!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpygy%2Fgosub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpygy%2Fgosub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpygy%2Fgosub/lists"}