Détail du package

gulp-yaml

crissdev26.5kMIT2.0.4

Convert YAML to JSON

gulpplugin, gulp-plugin, gulp, yaml

readme

gulp-yaml

JavaScript Style Guide npm version Build Status Build status Dependency Status

A Gulp plugin to convert YAML to JSON using js-yaml.

Install

npm install gulp-yaml --save-dev

Usage

const yaml = require('gulp-yaml');

gulp.src('./src/*.yml')
  .pipe(yaml({ schema: 'DEFAULT_SAFE_SCHEMA' }))
  .pipe(gulp.dest('./dist/'))

gulp.src('./src/*.yml')
  .pipe(yaml({ space: 2 }))
  .pipe(gulp.dest('./dist/'))

gulp.src('./src/*.yml')
  .pipe(yaml({ safe: true }))
  .pipe(gulp.dest('./dist/'))

API

yaml([options])

options.safe

Type: Boolean

Default: true

Enable or disable support for regexps, functions and undefined.

This flag should always be enabled when working with untrusted data.

When this flag is enabled then safeLoad method is used, otherwise load.

options.space

Type: Number or String

Default: null

Control spacing in the resulting output. It has the same usage as for JSON.stringify

options.replacer

Type: Function or Array

Default: null

Further transform the resulting output. It has the same usage as for JSON.stringify

options.schema

Type: String

Default: DEFAULT_SAFE_SCHEMA or DEFAULT_FULL_SCHEMA

Specifies what schema to use. Valid values are the same that js-yaml supports, except they are received as strings (lowercase or uppercase). See the example in the Usage section of this README. The default schema is chosen using the safe option.

options.filename

Type: String

Default: the path of the file processed

String to be used as a file path in error/warning messages.

options.ext

Type: String

Default: .json

File extension of the generated file.

options.json

Type: Boolean

Default: false

Compatibility with JSON.parse behaviour. If true, then duplicate keys in a mapping will override values rather than throwing an error.

options.onWarning

Type: Function

Default: null

Function to call on warning messages. Loader will throw on warnings if this function is not provided.

License

MIT © Cristian Trifan

changelog

2.0.4 (2019-05-01)

  • upgrade development & production dependencies

2.0.3 (2019-01-24)

2.0.2 (2018-08-17)

Dependencies

  • upgrade development & production dependencies

2.0.1 (2018-04-15)

Bug Fixes

  • plugin mutates provided options (5be4a64)

2.0.0 (2018-04-12)

User features

Add options.ext to specify the filename extension (defaults to .json).

Add options.json and options.onWarning from js-yaml.

Add support for file.contents being null.

Documentation

Improve README.md.

Dependencies

Remove gulp-util deprecated dependency.

Upgrade js-yaml from 3.4.3 to 3.11.0

Upgrade bufferstreams from 1.1.0 to 2.0.0

Add package-lock.json

Linting

Add linting with ESLint. It is based on Standard JavaScript.

Refactoring

Major code refactoring.

1.0.1 (2015-10-22)

Bug Fixes

  • error thrown when multiple files are processed #4

1.0.0 (2015-10-17)

Features

  • add support for schema option. The option must be specified as string, lower or upper case.
  • add support for filename option. The default value will be set to the path of file being processed.

Breaking changes

  • safe option is true by default
  • removed pretty option. Use the space option instead (e.g space: 2). This means more control of the output.

Maintenance

  • updated js-yaml dependency to its latest version available (3.4.3)
  • remove iojs and use node stable version instead

0.2.4 (2015-03-15)

  • target node.js 0.12 and io.js for Travis CI
  • updated js-yaml dependency to its latest version available (3.2.7)
  • option name for replacer was not correct in README.md

0.2.3 (2014-12-01)

  • unsafe file was tested only in stream mode
  • updated js-yaml dependency to its latest version available (3.2.3)

0.2.2 (2014-10-04)

  • use new Github user name

0.2.1 (2014-09-26)

Bug Fixes

  • change resulting file extension to .json in stream mode

0.2.0 (2014-09-19)

Features

  • add support for streams
  • add new options space and replacer to have a better control of the output
  • upgrade js-yaml dependency to its last version available (3.2.2)

The pretty option has been deprecated, and space option should be used instead

0.1.0 (2014-08-26)

Features

  • upgrade js-yaml dependency to its last version available (3.2.1)

Breaking changes

  • Because this plugin uses js-yaml this version might add some breaking changes. Please check js-yaml Breaking changes for potential issues and how to fix them.

0.0.3 (2014-07-24)

Features

  • add safe to the list of supported options. The default value is false to maintain compatibility with previous versions. If you suspect to have untrusted YAML in your project files, then turn this flag on.

0.0.2 (2014-07-23)

Features

  • README.md add badges for npm version, build status and dependency status

0.0.1 (2014-07-23)

Features

  • add pretty to the list of supported options. If this flag is true then resulting JSON will be pretty printed. The default value is false.