{"id":18604021,"url":"https://github.com/henrycunh/haxx","last_synced_at":"2025-10-22T02:58:06.978Z","repository":{"id":43338061,"uuid":"462360138","full_name":"henrycunh/haxx","owner":"henrycunh","description":"⚡️ Makes writing scripts absurdly easy","archived":false,"fork":false,"pushed_at":"2023-05-22T04:13:39.000Z","size":217,"stargazers_count":15,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-11T07:25:14.470Z","etag":null,"topics":["fetch","io","javascript","json","scripts","typescript","yaml","zx"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/henrycunh.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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":"2022-02-22T15:32:40.000Z","updated_at":"2023-12-27T16:41:54.000Z","dependencies_parsed_at":"2024-06-20T23:40:08.501Z","dependency_job_id":null,"html_url":"https://github.com/henrycunh/haxx","commit_stats":null,"previous_names":["henrycunh/isw"],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/henrycunh/haxx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henrycunh%2Fhaxx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henrycunh%2Fhaxx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henrycunh%2Fhaxx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henrycunh%2Fhaxx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/henrycunh","download_url":"https://codeload.github.com/henrycunh/haxx/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henrycunh%2Fhaxx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280370891,"owners_count":26319317,"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","status":"online","status_checked_at":"2025-10-22T02:00:06.515Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["fetch","io","javascript","json","scripts","typescript","yaml","zx"],"created_at":"2024-11-07T02:16:17.138Z","updated_at":"2025-10-22T02:58:06.927Z","avatar_url":"https://github.com/henrycunh.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# haxx\n  \u003csup\u003eeasily create and run scripts using javascript\u003c/sup\u003e\n\n\u003c/div\u003e\n\n\n\u003cp align=\"center\"\u003e\n  \u003ctable\u003e\n    \u003ctbody\u003e\n      \u003ctd align=\"center\"\u003e\n        \u003cimg width=\"2000\" height=\"0\"\u003e\u003cbr\u003e\n        \u003ca href=\"#getting-started\"\u003egetting started\u003c/a\u003e • \u003ca href=\"#installation\"\u003ecommands\u003c/a\u003e • \u003ca href=\"#api\"\u003eapi\u003c/a\u003e\u003cbr\u003e\n        \u003cimg width=\"2000\" height=\"0\"\u003e\n      \u003c/td\u003e\n    \u003c/tbody\u003e\n  \u003c/table\u003e\n\u003c/p\u003e\n\n## Features\n- 🔀 **Process DX** - easily manage and run processes\n- 📦 **Javascript ESM** - makes writing scripts easier, through javascript\n- 🔌 **Great IO** - provides easy to use IO functions, for known formats\n- 🧑‍💻 **Opinionated** - it's a great tool for writing tools, with tools inside\n\n## Getting started\nIt's as simple as creating a script file with a `.mjs` extension\n```js\n#!/usr/bin/env haxx\n\nconst lastTag = await $`git tag | tail -n 1`\nconst tagMessage = String(await $`git tag -l -n9 ${lastTag}`)\n    .match(/\\s{2,}(.+)/)[1]\nconsole.log(`Last tag message: ${tagMessage}`)\n```\nAnd running it\n```bash\nhaxx my-script.mjs\n```\n## Installation\nYou can either install it globally\n```bash\nnpm i -g haxx\nhaxx my-script.mjs\n```\nOr run it through `npx` or any other package manager execute\n```bash\nnpx -y haxx my-script.mjs\n```\n## API\n### `$`\n**Executes a given command and returns a promise of the output.**\n\nEverything passed through `${...}` will be automatically escaped and quoted.\n\n\n```js\nconst dirToRemove = 'my nice dir'\nawait $`rm -rf ${dirToRemove}` // rm -rf 'my nice dir'\n```\n\nYou can pass arrays as arguments\n```js\nconst dirs = ['dir1', 'dir2']\nawait $`ls ${dirs}` // ls dir1 dir2\n```\n\nYou can catch process exit codes upon a failing\n```js\ntry {\n    await $`exit 1`\n} catch (process) {\n    console.log(`Exit code: ${process.exitCode}`)\n    console.log(`Error: ${process.stderr}`)\n}\n```\n\nYou can pipe directly from the promise to any other stream\n```js\n$`watch -n1 ls`.pipe(process.stdout)\n```\n\n### `read`\nLets you read files easily, and specify formats\n```js\nconst content = await read`my-file.txt`\n\nconst package = await read.json`package.json`\nconsole.log(package.version)\n\nconst deployment = await read.yaml`deployment.yaml`\nconsole.log(deployment.metadata.name)\n```\n\n### `write`\nLets you write files easily, and specify formats\n```js\nawait write('my-file', 'Hello world') \n// Hello World\n\nawait write.json('object.json', { hello: 'world' })\n// { \"hello\": \"world\" }\n\nawait write.yaml('object.yaml', { hello: 'world' })\n// hello: world\n```\n\n### `io`\nGives you a nice interface for reading and saving files\n\n```js\nconst { data: pkg, save } = await io.json`package.json`\npkg.version = '1.0.1'\nawait save()\n\nconst { data: deployment, save: saveDeployment } = await io.yaml`deployment.yaml`\ndeployment.spec.template.spec.containers[0].image = 'my-new-image'\nawait saveDeployment()\n```\n\n### `exists`\nChecks if a file or directory exists\n```js\nif (!exists('key')) {\n    await write('key', Math.random().toString().slice(2))\n}\n```\n\n### `remove`\nRemoves a file or directory\n```js\nremove('my-file')\n```\n\n### `cd`\nChanges the directory\n```js\nawait $`ls`\ncd('another-directory')\nawait $`ls`\n```\n\n### `template`\nLets you replace variables in a template\n```js\nconst phrase = template({ name: 'world'}, 'Hello {{ name }}')\n\nconst filled = template.file({ GITHUB_TOKEN: '...' }, 'my-template')\n```\n\n### Included batteries\n\n- `kleur` - a nice color library\n- `kleur-template` - easier coloring through templating\n- `glob` - utility for globbing files\n- `yaml` - a yaml parser\n- `os` - the os package\n- `path` - the path package\n- `minimist` - your arguments parsed, availabe through the global constant `argv`\n## Acknowledgements\nThis project is **heavily** inspired by [**zx**](https://github.com/google/zx) and [**fsxx**](https://github.com/antfu/fsxx), down to the code. \n\nCheck them out!\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhenrycunh%2Fhaxx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhenrycunh%2Fhaxx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhenrycunh%2Fhaxx/lists"}