Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cfware/gulp-add-json-file
Add a JSON formatted file to a gulp stream.
https://github.com/cfware/gulp-add-json-file
gulp gulpplugin json vinyl
Last synced: about 2 months ago
JSON representation
Add a JSON formatted file to a gulp stream.
- Host: GitHub
- URL: https://github.com/cfware/gulp-add-json-file
- Owner: cfware
- License: mit
- Created: 2019-02-02T16:48:59.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-05-27T14:33:59.000Z (over 4 years ago)
- Last Synced: 2024-11-20T18:02:21.698Z (about 2 months ago)
- Topics: gulp, gulpplugin, json, vinyl
- Language: JavaScript
- Size: 27.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# gulp-add-json-file
[![Travis CI][travis-image]][travis-url]
[![Greenkeeper badge][gk-image]](https://greenkeeper.io/)
[![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]
[![MIT][license-image]](LICENSE)Add a JSON formatted file to a gulp stream.
### Install gulp-add-json-file
This module requires node.js 13.8.0 or above.
```sh
npm i -D gulp gulp-add-json-file
```## Usage
```js
import {promisify} from 'util';
import stream from 'stream';import gulp from 'gulp';
import gulpAddJSON from 'gulp-add-json-file';const pipeline = promisify(stream.pipeline);
gulp.task('default', () => {
/* Copy 'src/**' to 'dest', add 'filename.json' from JS object. */
return pipeline(
gulp.src('src/**'),
gulpAddJSON('filename.json', {field: 'value'}),
gulp.dest('dest')
);
});
```### gulpAddJSON(filename, object, space)
* **filename**: The filename to use when adding a vinyl object
* **object**: The JavaScript object to stringify as contents of the vinyl object
* **space**: Passed directly to [JSON.stringify].## U+2028 and U+2029
Literal code points U+2028 and U+2029 are escaped for maximum compatibility.
## Duplicate files
This module should not be used to add a duplicate filename to the gulp stream. In
the above example if `src/filename.json` exists it should be filtered out from
`gulp.src`.[npm-image]: https://img.shields.io/npm/v/gulp-add-json-file.svg
[npm-url]: https://npmjs.org/package/gulp-add-json-file
[travis-image]: https://travis-ci.org/cfware/gulp-add-json-file.svg?branch=master
[travis-url]: https://travis-ci.org/cfware/gulp-add-json-file
[gk-image]: https://badges.greenkeeper.io/cfware/gulp-add-json-file.svg
[downloads-image]: https://img.shields.io/npm/dm/gulp-add-json-file.svg
[downloads-url]: https://npmjs.org/package/gulp-add-json-file
[license-image]: https://img.shields.io/npm/l/gulp-add-json-file.svg
[JSON.stringify]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_space_argument