How to use the js-yaml.DEPLOY_SCHEMA function in js-yaml

To help you get started, we’ve selected a few js-yaml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ttiny / deploy / src / YamlHelpers.js View on Github external
"use strict";

var Yaml = require( 'js-yaml' );
var Cmd = require( './yamltypes/Cmd' );
var Echo = require( './yamltypes/Echo' );
var YamlFile = require( './yamltypes/YamlFile' );
var YamlFiles = require( './yamltypes/YamlFiles' );
var TextFile = require( './yamltypes/TextFile' );
var Deploy = require( './yamltypes/Deploy' );
var If = require( './yamltypes/If' );
var DeferredYaml = require( './yamltypes/Deferred' );
var Fs = require( 'fs' );

Yaml.DEPLOY_SCHEMA = Yaml.Schema.create( Yaml.DEFAULT_FULL_SCHEMA, [ Deploy, If, Cmd, Echo, YamlFile, YamlFiles, TextFile ] );

global.yaml = function ( yaml, vars ) {
	if ( yaml instanceof DeferredYaml ) {
		return yaml.resolve( vars );
	}
	else if ( yaml instanceof Function ) {
		return yaml( global, require, vars );
	}

	return yaml;
}

global.LoadYaml = function ( file ) {
	if ( !Fs.existsSync( file ) ) {
		return null;
	}
github ttiny / deploy / src / YamlHelpers.js View on Github external
global.LoadYaml = function ( file ) {
	if ( !Fs.existsSync( file ) ) {
		return null;
	}
	var config = Fs.readFileSync( file, 'utf8' );
	return Yaml.load( config, { filename: file, schema: Yaml.DEPLOY_SCHEMA } );
}