{"id":15357142,"url":"https://github.com/chocolateboy/shell-escape-tag","last_synced_at":"2025-04-15T06:43:11.194Z","repository":{"id":1349336,"uuid":"42387702","full_name":"chocolateboy/shell-escape-tag","owner":"chocolateboy","description":"An ES6 template tag which escapes parameters for interpolation into shell commands","archived":false,"fork":false,"pushed_at":"2023-01-06T01:51:50.000Z","size":728,"stargazers_count":15,"open_issues_count":14,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-15T06:43:06.207Z","etag":null,"topics":["cli","command-line","es2015","es6","escape","escaping","quote","quoting","shell","template-string"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"artistic-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chocolateboy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-13T07:37:51.000Z","updated_at":"2022-09-08T05:12:50.000Z","dependencies_parsed_at":"2023-01-13T11:45:17.298Z","dependency_job_id":null,"html_url":"https://github.com/chocolateboy/shell-escape-tag","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chocolateboy%2Fshell-escape-tag","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chocolateboy%2Fshell-escape-tag/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chocolateboy%2Fshell-escape-tag/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chocolateboy%2Fshell-escape-tag/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chocolateboy","download_url":"https://codeload.github.com/chocolateboy/shell-escape-tag/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249023727,"owners_count":21199958,"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":["cli","command-line","es2015","es6","escape","escaping","quote","quoting","shell","template-string"],"created_at":"2024-10-01T12:33:26.429Z","updated_at":"2025-04-15T06:43:11.177Z","avatar_url":"https://github.com/chocolateboy.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://github.com/chocolateboy/shell-escape-tag/workflows/test/badge.svg)](https://github.com/chocolateboy/shell-escape-tag/actions?query=workflow%3Atest)\n[![NPM Version](https://img.shields.io/npm/v/shell-escape-tag.svg)](https://www.npmjs.org/package/shell-escape-tag)\n\n\u003c!-- TOC --\u003e\n\n- [NAME](#name)\n- [INSTALL](#install)\n- [SYNOPSIS](#synopsis)\n- [DESCRIPTION](#description)\n- [EXPORTS](#exports)\n  - [shell (default)](#shell-default)\n- [FUNCTIONS](#functions)\n  - [shell.escape](#shellescape)\n  - [shell.preserve](#shellpreserve)\n- [DEVELOPMENT](#development)\n- [COMPATIBILITY](#compatibility)\n- [SEE ALSO](#see-also)\n- [VERSION](#version)\n- [AUTHOR](#author)\n- [COPYRIGHT AND LICENSE](#copyright-and-license)\n\n\u003c!-- TOC END --\u003e\n\n# NAME\n\nshell-escape-tag - an ES6 template tag which escapes parameters for interpolation into shell commands\n\n# INSTALL\n\n    $ npm install shell-escape-tag\n\n# SYNOPSIS\n\n```javascript\nimport shell from 'shell-escape-tag'\n\nlet filenames = glob('Holiday Snaps/*.jpg')\nlet title     = 'Holiday Snaps'\nlet command   = shell`compress --title ${title} ${filenames}`\n\nconsole.log(command) // compress --title 'Holiday Snaps' 'Holiday Snaps/Pic 1.jpg' 'Holiday Snaps/Pic 2.jpg'\n```\n\n# DESCRIPTION\n\nThis module exports an ES6 tagged-template function which escapes (i.e. quotes)\nits parameters for safe inclusion in shell commands. Parameters can be strings,\narrays of strings, or nested arrays of strings, arrays and already-processed\nparameters.\n\nThe exported function also provides two helper functions which respectively\n[escape](#shellescape) and [preserve](#shellpreserve) their parameters and protect them\nfrom further processing.\n\n# EXPORTS\n\n## shell (default)\n\n**Signature**: (template: string) → string\n\n```javascript\nimport shell from 'shell-escape-tag'\n\nlet filenames = ['foo bar', \"baz's quux\"]\nlet title     = 'My Title'\nlet command   = shell`command --title ${title} ${filenames}`\n\nconsole.log(command) // command --title 'My Title' 'foo bar' 'baz'\"'\"'s quux'\n```\n\nTakes a [template literal](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals)\nand escapes any interpolated parameters. `null` and `undefined` values are\nignored. Arrays are flattened and their elements are escaped and joined with a\nspace. All other values are stringified i.e. `false` is mapped to `\"false\"`\netc. Parameters that have been escaped with [`shell.escape`](#shellescape) or\npreserved with [`shell.preserve`](#shellpreserve) are passed through verbatim.\n\n# FUNCTIONS\n\n## shell.escape\n\n**Signature**: (...args: any[]) → object\n\n```javascript\nimport shell from 'shell-escape-tag'\n\nlet escaped = shell.escape(\"foo's bar\")\nlet command1 = `command ${escaped}`\nlet command2 = shell`command ${escaped}`\n\nconsole.log(command1) // command 'foo'\"'\"'s bar'\nconsole.log(command2) // command 'foo'\"'\"'s bar'\n```\n\nFlattens, compacts and escapes any parameters which haven't already been\nescaped or preserved, joins the resulting elements with a space, and wraps the\nresulting string in an object which remains escaped when embedded in a template\nor passed as a direct or nested parameter to [`shell`](#shell-default),\n[`shell.escape`](#shellescape), or [`shell.preserve`](#shellpreserve).\n\n## shell.preserve\n\n**Aliases**: protect, verbatim\n\n**Signature**: (...args: any[]) → object\n\n```javascript\nimport shell from 'shell-escape-tag'\n\nlet preserved = shell.preserve(\"baz's quux\")\nlet command1 = `command \"${preserved}\"`\nlet command2 = shell`command \"${preserved}\"`\n\nconsole.log(command1) // command \"baz's quux\"\nconsole.log(command2) // command \"baz's quux\"\n```\n\nFlattens, compacts and preserves any parameters which haven't already been\nescaped or preserved, joins the resulting elements with a space, and wraps the\nresulting string in an object which is passed through verbatim when embedded in\na template or passed as a direct or nested parameter to\n[`shell`](#shell-default), [`shell.escape`](#shellescape), or\n[`shell.preserve`](#shellpreserve).\n\n# DEVELOPMENT\n\n\u003cdetails\u003e\n\n\u003c!-- TOC:ignore --\u003e\n## NPM Scripts\n\nThe following NPM scripts are available:\n\n- build - compile the code and save it to the `dist` directory\n- build:doc - generate the README's TOC (table of contents)\n- clean - remove the `dist` directory and other build artifacts\n- rebuild - clean the build artifacts and recompile the code\n- test - clean and rebuild and run the test suite\n- test:run - run the test suite\n\n\u003c/details\u003e\n\n# COMPATIBILITY\n\n- [Maintained Node.js versions](https://github.com/nodejs/Release#readme) (and compatible browsers)\n\n# SEE ALSO\n\n- [any-shell-escape](https://www.npmjs.com/package/any-shell-escape) - escape and stringify an array of arguments to be executed on the shell\n- [execa](https://www.npmjs.com/package/execa) - a better `child_process`\n- [@perl/qw](https://www.npmjs.com/package/@perl/qw) - a template tag for quoted word literals like Perl's `qw(...)`\n- [@perl/qx](https://www.npmjs.com/package/@perl/qx) - a template tag to run a command and capture its output like Perl's `qx(...)`\n- [puka](https://www.npmjs.com/package/puka) - a cross-platform library for safely passing strings through shells\n\n# VERSION\n\n2.0.2\n\n# AUTHOR\n\n[chocolateboy](mailto:chocolate@cpan.org)\n\n# COPYRIGHT AND LICENSE\n\nCopyright © 2015-2020 by chocolateboy.\n\nThis is free software; you can redistribute it and/or modify it under the terms\nof the [Artistic License 2.0](https://www.opensource.org/licenses/artistic-license-2.0.php).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchocolateboy%2Fshell-escape-tag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchocolateboy%2Fshell-escape-tag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchocolateboy%2Fshell-escape-tag/lists"}