{"id":20614744,"url":"https://github.com/dashed/gulp-spawn-shim","last_synced_at":"2026-04-19T02:04:25.890Z","repository":{"id":13153473,"uuid":"15836132","full_name":"dashed/gulp-spawn-shim","owner":"dashed","description":"Thin wrapper (shim) of Node.js's child_process.spawn() with respect to gulp (vinyl file streams) by binding to stdin, stdout, and stderr.","archived":false,"fork":false,"pushed_at":"2014-03-12T15:59:03.000Z","size":508,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-17T11:37:23.121Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/dashed.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}},"created_at":"2014-01-12T04:06:44.000Z","updated_at":"2014-03-12T15:59:04.000Z","dependencies_parsed_at":"2022-09-15T21:00:22.011Z","dependency_job_id":null,"html_url":"https://github.com/dashed/gulp-spawn-shim","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dashed%2Fgulp-spawn-shim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dashed%2Fgulp-spawn-shim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dashed%2Fgulp-spawn-shim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dashed%2Fgulp-spawn-shim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dashed","download_url":"https://codeload.github.com/dashed/gulp-spawn-shim/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242269117,"owners_count":20100071,"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":[],"created_at":"2024-11-16T11:13:30.197Z","updated_at":"2025-10-31T20:02:57.461Z","avatar_url":"https://github.com/dashed.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[gulp](https://github.com/gulpjs/gulp)-spawn-shim\n===============\n\n[![NPM version](https://badge.fury.io/js/gulp-spawn-shim.png)](http://badge.fury.io/js/gulp-spawn-shim)\n[![Build Status](https://travis-ci.org/Dashed/gulp-spawn-shim.png?branch=master)](https://travis-ci.org/Dashed/gulp-spawn-shim)\n[![Coverage Status](https://coveralls.io/repos/Dashed/gulp-spawn-shim/badge.png?branch=master)](https://coveralls.io/r/Dashed/gulp-spawn-shim?branch=master)\n[![Dependency Status](https://david-dm.org/Dashed/gulp-spawn-shim.png)](https://david-dm.org/Dashed/gulp-spawn-shim)\n\nThin wrapper (shim) of Node.js's [child_process.spawn()](http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options) with respect to gulp (vinyl file streams) by binding to stdin, stdout, and stderr.\n\nSupports both streaming and buffer modes (for vinyl) specified in the [gulp](https://github.com/gulpjs/gulp) plugin guidelines.\n\n**Note:** Gulp stream objects known as [vinyl](https://github.com/wearefractal/vinyl) objects.\n\nAn alternative to this plugin is [gulp-spawn](https://github.com/hparra/gulp-spawn).\n\n\n## Install\n\n1. Install [Node.js](http://nodejs.org/)\n\n2.  Run: `npm install gulp-spawn-shim`\n\n## API\n\n### gspawn(options [, callback])\n\n### gspawn(callback)\n\n#### Arguments\n\n* `options` -- an object containing options for gulp-spawn-shim\n\n* `callback` -- callback function with signature `function(file, opts, cb)`\n\n   The callback function is invoked before `child_process.spawn(...)` is executed.\n\n   The callback function is passed the file (vinyl object), and opts (a filtered object of the one passed to `spawn()`).\n\n   If `options` is excluded, the callback function is passed an empty options objects from which you must populate. This is useful for when you want to dynamically execute different `child_process.spawn()` profiles on various files.\n\n##### Options\n\n[child_process.spawn](nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options) parameters:\n\n* `options.cmd` - ***(String)*** cmd parameter of [child_process.spawn](nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options). **Required**\n\n* `options.args` - ***(Array)*** args parameter of [child_process.spawn](nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options). ***Default:*** Empty array\n\n* `options.options` - ***(Object)*** options parameter of [child_process.spawn](nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options). ***Default:*** undefined\n\n### Arg Templates\n\nAvailable for args are placeholders made available for you to use. These placeholders...\n\n* `\u003c%= basename %\u003e` - placeholder for file's basename (e.g. `quux.html`)\n\n* `\u003c%= extname %\u003e` - placeholder for file's extension (e.g. `.html`)\n\n* `\u003c%= filename %\u003e` - placeholder for file's filename (e.g. `quux`)\n\n**Note:** Template placeholders are done via [gulp-util.template()](https://github.com/gulpjs/gulp-util), which itself uses [lodash templates](http://lodash.com/docs#template).\n\n\n### Events\n\ngulp-spawn-shim emit several events, some from the plugin itself, and other from child_process.spawn().\n\n* `failure` -- Default error handler for internal plugin errors.\n\n   Since this plugin uses [async-queue-stream](https://github.com/Dashed/async-queue-stream/) internally, the default error is `failure` instead of the standard stream `error` event. Therefore, **this plugin does not stop processing files when a file coerce a plugin error**.\n\n   Handler signature: `.on('failure', function(err) {})`\n\n* `stderr` -- stderr output from child_process.spawn(). stderr output is textual.\n\n   Handler signature: `.on('stderr', function(stderr) {})`\n\n* `exit` -- exit code from child_process.spawn(). exit code passed is a number.\n\n   Handler signature: `.on('exit', function(exit) {})`\n\nUsage\n=====\n\n```js\nvar\nspawn = require('gulp-spawn-shim'),\nopts = {};\n\nopts.cmd = 'pandoc';\nopts.args = ['-t', 'html'];\n\ngulp.src('./notes/**/*.md')\n    .pipe(spawn(opts))\n    .pipe(gulp.dest(...));\n```\n\n## Under the hood\n\n1. As vinyl objects are passed to gulp-spawn-shim, contents of the file (e.g. `file.contents`) are piped to ***stdin*** of the child_process.spawn() instance.\n\n2. Any ***stdout*** are piped back to `file.contents`.\n\n   **Note:** If there is no ***stdout***, gulp-spawn-shim will not push the file to the next stream -- and thus the file will be **dropped silently**.\n\n3. Any misc. events such as ***stderr*** and ***exit codes*** are emitted appropriately.\n\n\nLicense\n=======\n\nMIT. See LICENSE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdashed%2Fgulp-spawn-shim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdashed%2Fgulp-spawn-shim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdashed%2Fgulp-spawn-shim/lists"}