{"id":15700062,"url":"https://github.com/jonschlinkert/gulp-data-contents","last_synced_at":"2025-05-12T13:08:57.500Z","repository":{"id":57257299,"uuid":"98741255","full_name":"jonschlinkert/gulp-data-contents","owner":"jonschlinkert","description":"Gulp plugin that replaces the contents of a file with the contents of another file using the filepath specified on the 'contents' property in front-matter. Customizable, useful for generating scaffolding or defining placeholder files.","archived":false,"fork":false,"pushed_at":"2017-08-07T06:38:56.000Z","size":10,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-12T13:08:47.920Z","etag":null,"topics":["contents","data","front-matter","generate","generator","gulp","gulp-plugins","gulpplugin","placeholder","replace","scaffolding","templates"],"latest_commit_sha":null,"homepage":"https://github.com/jonschlinkert","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/jonschlinkert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-29T15:27:14.000Z","updated_at":"2021-04-12T22:28:48.000Z","dependencies_parsed_at":"2022-09-08T08:50:12.707Z","dependency_job_id":null,"html_url":"https://github.com/jonschlinkert/gulp-data-contents","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fgulp-data-contents","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fgulp-data-contents/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fgulp-data-contents/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fgulp-data-contents/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonschlinkert","download_url":"https://codeload.github.com/jonschlinkert/gulp-data-contents/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253745160,"owners_count":21957317,"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":["contents","data","front-matter","generate","generator","gulp","gulp-plugins","gulpplugin","placeholder","replace","scaffolding","templates"],"created_at":"2024-10-03T19:44:59.355Z","updated_at":"2025-05-12T13:08:57.462Z","avatar_url":"https://github.com/jonschlinkert.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gulp-data-contents [![NPM version](https://img.shields.io/npm/v/gulp-data-contents.svg?style=flat)](https://www.npmjs.com/package/gulp-data-contents) [![NPM monthly downloads](https://img.shields.io/npm/dm/gulp-data-contents.svg?style=flat)](https://npmjs.org/package/gulp-data-contents) [![NPM total downloads](https://img.shields.io/npm/dt/gulp-data-contents.svg?style=flat)](https://npmjs.org/package/gulp-data-contents) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/gulp-data-contents.svg?style=flat\u0026label=Travis)](https://travis-ci.org/jonschlinkert/gulp-data-contents)\n\n\u003e Gulp plugin that replaces the contents of a file with the contents of another file using the filepath specified on the 'contents' property in front-matter. Customizable, useful for generating scaffolding or defining placeholder files.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save gulp-data-contents\n```\n\n## What does this do?\n\nGiven you have a file with the following [front-matter](https://github.com/jonschlinkert/gray-matter):\n\n```\n---\ncontents: scaffold.txt\n---\n```\n\nThis plugin will replace the contents of the file with the contents from `scaffold.txt`.\n\n## Usage\n\n```js\nvar gulp = require('gulp');\nvar contents = require('gulp-data-contents');\n\ngulp.task('contents', function() {\n  return gulp.src('example.txt')\n    .pipe(contents())\n    .pipe(gulp.dest('dist'));\n});\n```\n\n## Options\n\n### options.prop\n\nCustomize the file property to use. By default, `file.data.contents` is used.\n\n**Type:**: `string`\n\n**Default:**: `data.contents`\n\n**Example**\n\n```js\ncontents({prop: 'data.value'})\n```\n\nWhich would be used like this:\n\n```\n---\nvalue: scaffold.txt\n---\n```\n\nNote that [gray-matter](https://github.com/jonschlinkert/gray-matter) (the front-matter parser used by [assemble](https://github.com/assemble/assemble), [metalsmith](https://github.com/segmentio/metalsmith), the [electron](https://github.com/electron-userland/electron-prebuilt) website and many others, uses the `file.data` property for front-matter. Other libraries might use a different property).\n\n### options.cwd\n\nCustomize current working directory to use for filepath specified in front-matter. If not specified, `file.base` is used as the cwd.\n\n**Type:**: `string`\n\n**Default:**: `undefined`\n\n**Example**\n\n```js\ncontents({cwd: 'templates'})\n```\n\n### options.resolve\n\nCustom function for resolving `file.contents` from the path defined in front-matter.\n\n**Type:**: `function`\n\n**Default:** Uses `fs.readFileSync()`\n\n**Example**\n\n```js\ncontents({\n  resolve: function(file, options, next) {\n    var fp = path.join('some/path', file.data.contents);\n    file.contents = fs.readFileSync(fp);\n    next(null, file);\n  }\n})\n```\n\n## About\n\n### Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\nPlease read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards.\n\n### Building docs\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme \u0026\u0026 verb\n```\n\n### Running tests\n\nRunning and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:\n\n```sh\n$ npm install \u0026\u0026 npm test\n```\n\n### Author\n\n**Jon Schlinkert**\n\n* [github/jonschlinkert](https://github.com/jonschlinkert)\n* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)\n\n### License\n\nCopyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on August 07, 2017._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fgulp-data-contents","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonschlinkert%2Fgulp-data-contents","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fgulp-data-contents/lists"}