{"id":48102327,"url":"https://github.com/kagal-dev/cross-test","last_synced_at":"2026-04-04T15:45:20.610Z","repository":{"id":343757291,"uuid":"1179020980","full_name":"kagal-dev/cross-test","owner":"kagal-dev","description":"Cross-platform shell-style conditions for `package.json` scripts","archived":false,"fork":false,"pushed_at":"2026-03-26T01:53:28.000Z","size":86,"stargazers_count":1,"open_issues_count":10,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-26T18:38:28.634Z","etag":null,"topics":["cli","cross-platform","developer-tools","esm","nodejs","npm-package","posix","shell","typescript","zero-dependencies"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@kagal/cross-test","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/kagal-dev.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,"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":"2026-03-11T15:53:50.000Z","updated_at":"2026-03-25T19:18:11.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/kagal-dev/cross-test","commit_stats":null,"previous_names":["kagal-dev/cross-test"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/kagal-dev/cross-test","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kagal-dev%2Fcross-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kagal-dev%2Fcross-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kagal-dev%2Fcross-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kagal-dev%2Fcross-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kagal-dev","download_url":"https://codeload.github.com/kagal-dev/cross-test/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kagal-dev%2Fcross-test/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31403961,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T10:20:44.708Z","status":"ssl_error","status_checked_at":"2026-04-04T10:20:06.846Z","response_time":60,"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":["cli","cross-platform","developer-tools","esm","nodejs","npm-package","posix","shell","typescript","zero-dependencies"],"created_at":"2026-04-04T15:45:20.091Z","updated_at":"2026-04-04T15:45:20.592Z","avatar_url":"https://github.com/kagal-dev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cross-test 🛠️\n\n**Cross-platform shell-style conditions for `package.json` scripts.**\n\n`cross-test` is a lightweight, zero-dependency CLI utility\nthat brings Unix-like `test` (or `[ ]`) functionality to\nany operating system. It allows you to write conditional\nlogic in your `package.json` scripts that works identically\non Windows, macOS, and Linux.\n\n---\n\n## 🚀 Why you need it\n\nStandard shell conditions are not portable:\n\n- **Unix:** `[ -f dist/index.js ] \u0026\u0026 echo \"Ready\"` (Fails on Windows CMD/PowerShell)\n- **Windows:** `if exist dist\\index.js echo Ready` (Fails on Bash/Zsh)\n- **cross-test:** `cross-test -f dist/index.js \u0026\u0026 echo \"Ready\"` (Works everywhere)\n\n## ✨ Features\n\n- 📦 **Zero Dependencies:** Keeps your `node_modules` tiny.\n- ⚡ **ESM-Native:** Built for the modern Node.js ecosystem.\n- 🔧 **Internal Variable Expansion:** Supports `$VAR` and `${VAR}` using `process.env`.\n- 🧠 **Smart Logic:** Full support for `!`, `-a` (AND), `-o` (OR), and `( )` grouping.\n- 🛡️ **Provenance:** Published with OIDC trusted publishing\n  and SLSA provenance attestation.\n\n---\n\n## 📥 Installation\n\n```bash\nnpm install --save-dev @kagal/cross-test\n```\n\n## 🛠 Usage\n\nUse it directly in your `package.json` scripts:\n\n```json\n{\n  \"scripts\": {\n    \"dev\": \"cross-test -f dist/index.js || unbuild --stub\",\n    \"deploy\": \"cross-test '$NODE_ENV' = 'production' \u0026\u0026 npm run surge\",\n    \"check\": \"cross-test '(' -d .git -a -f .env ')' || echo 'Setup incomplete'\"\n  }\n}\n```\n\n### Supported Tests\n\n| Flag | Description |\n| :--- | :--- |\n| `-f \u003cpath\u003e` | True if path is a **file**. |\n| `-d \u003cpath\u003e` | True if path is a **directory**. |\n| `-e \u003cpath\u003e` | True if path **exists**. |\n| `-s \u003cpath\u003e` | True if path exists and has **size \u003e 0**. |\n| `-n \u003cstr\u003e`  | True if string has **non-zero length**. |\n| `-z \u003cstr\u003e`  | True if string is **empty**. |\n| `s1 = s2`   | True if string `s1` equals `s2`. |\n| `s1 != s2`  | True if string `s1` does not equal `s2`. |\n\n---\n\n## 📖 Grammar\n\n`cross-test` uses a recursive descent parser.\nPrecedence from lowest to highest:\n\n```ebnf\nexpr    = or ;\nor      = and { \"-o\" and } ;\nand     = primary { \"-a\" primary } ;\nprimary = \"!\" primary\n        | \"(\" expr \")\"\n        | string ( \"=\" | \"!=\" ) string\n        | ( \"-n\" | \"-z\" ) string\n        | ( \"-d\" | \"-e\" | \"-f\" | \"-s\" ) path\n        ;\n```\n\nVariables (`$VAR`, `${VAR}`) are expanded from\n`process.env` before parsing.\n\n---\n\n## 🔒 Security\n\nThis package is published using **OIDC trusted publishing**\nand includes a verifiable **SLSA provenance** attestation.\nYou can verify that the code in the npm package matches the\nsource code in the GitHub repository.\n\n## 📄 License\n\nMIT © 2026\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkagal-dev%2Fcross-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkagal-dev%2Fcross-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkagal-dev%2Fcross-test/lists"}