{"id":13657242,"url":"https://github.com/esamattis/sh-thunk","last_synced_at":"2026-04-03T00:09:02.812Z","repository":{"id":44176532,"uuid":"123495367","full_name":"esamattis/sh-thunk","owner":"esamattis","description":"Generate promise returning thunks from shell strings.","archived":false,"fork":false,"pushed_at":"2023-01-04T21:35:55.000Z","size":1257,"stargazers_count":1,"open_issues_count":14,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-27T23:33:56.332Z","etag":null,"topics":["nodejs","shell"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/sh-thunk","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/esamattis.png","metadata":{"files":{"readme":"README.md","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":"2018-03-01T21:38:13.000Z","updated_at":"2020-10-17T11:06:15.000Z","dependencies_parsed_at":"2023-02-02T20:45:13.726Z","dependency_job_id":null,"html_url":"https://github.com/esamattis/sh-thunk","commit_stats":null,"previous_names":["epeli/gulp-sh","epeli/sh-thunk"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/esamattis/sh-thunk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esamattis%2Fsh-thunk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esamattis%2Fsh-thunk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esamattis%2Fsh-thunk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esamattis%2Fsh-thunk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/esamattis","download_url":"https://codeload.github.com/esamattis/sh-thunk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esamattis%2Fsh-thunk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29770766,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-24T03:15:54.600Z","status":"ssl_error","status_checked_at":"2026-02-24T03:15:54.143Z","response_time":75,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["nodejs","shell"],"created_at":"2024-08-02T05:00:39.086Z","updated_at":"2026-02-24T03:31:37.319Z","avatar_url":"https://github.com/esamattis.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# sh-thunk\n\nGenerate promise returning thunks from shell strings.\n\nThis makes it really simple to execute shell scripts from task runners\nsuchs as Gulp and [Jake][] which can take promise returning function as the task implementation.\n\n[jake]: https://jakejs.com/\n\nHere's an example of a `gulpfile.js`:\n\n```js\nconst { task, parallel } = require(\"gulp\");\nconst { sh } = require(\"sh-thunk\");\n\nconst jsfiles = [\"foo.js\", \"bar.js\"];\n\n// Simple commands\ntask(\"webpack-dev-server\", sh`webpack-dev-server --mode development`);\n\n// Expand arrays in tagged templates\ntask(\"eslint\", sh`eslint --max-warnings 0 ${jsfiles}`);\ntask(\"prettier\", sh`prettier --write ${jsfiles}`);\n\n// Run commands in parallel with gulp 4\ntest(\"test-all\", parallel(\"eslint\", \"test\"));\n\n// Multiline scripts\ntask(\n    \"fix-babel\",\n    sh`\n        find node_modules/ -name .babelrc -delete\n        find node_modules/ -name .babelrc.js -delete\n\n        # You can embed any shell scripts here\n        echo $(basename $HOME)\n    `,\n);\n```\n\n`jakefile.js` is basically the same:\n\n```js\nconst { task } = require(\"jake\");\nconst { sh } = require(\"sh-thunk\");\n\ntask(\"webpack\", sh`webpack --mode production`);\n```\n\nAlso useful in jest hooks:\n\n```js\n// generate 5MB file\nbeforeAll(sh`dd if=/dev/zero of=big.txt count=5k bs=1024 2\u003e /dev/null`);\n```\n\nThe scripts are executed with `sh -eu` and `./node_modules/.bin` is put to `PATH` automatically.\n\n## Capturing output\n\nThere's a `sh.capture` variant if you need to capture command output instead\nof piping it through.\n\n```js\nconst {\n    stdout,\n    stderr,\n    both,\n} = await sh.capture`git rev-parse --abbrev-ref HEAD`();\n```\n\nWhere `stdout` and `stderr` are strings of the corresponding output channels\nand `both` is string with both outputs interleaved as it would show up in the\nterminal.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fesamattis%2Fsh-thunk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fesamattis%2Fsh-thunk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fesamattis%2Fsh-thunk/lists"}