mirror of
https://github.com/dawidd6/action-ansible-playbook.git
synced 2025-12-09 22:30:41 -07:00
node_modules: upgrade
This commit is contained in:
55
node_modules/yaml/dist/nodes/addPairToJSMap.js
generated
vendored
55
node_modules/yaml/dist/nodes/addPairToJSMap.js
generated
vendored
@@ -1,24 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
var log = require('../log.js');
|
||||
var merge = require('../schema/yaml-1.1/merge.js');
|
||||
var stringify = require('../stringify/stringify.js');
|
||||
var identity = require('./identity.js');
|
||||
var Scalar = require('./Scalar.js');
|
||||
var toJS = require('./toJS.js');
|
||||
|
||||
const MERGE_KEY = '<<';
|
||||
function addPairToJSMap(ctx, map, { key, value }) {
|
||||
if (ctx?.doc.schema.merge && isMergeKey(key)) {
|
||||
value = identity.isAlias(value) ? value.resolve(ctx.doc) : value;
|
||||
if (identity.isSeq(value))
|
||||
for (const it of value.items)
|
||||
mergeToJSMap(ctx, map, it);
|
||||
else if (Array.isArray(value))
|
||||
for (const it of value)
|
||||
mergeToJSMap(ctx, map, it);
|
||||
else
|
||||
mergeToJSMap(ctx, map, value);
|
||||
}
|
||||
if (identity.isNode(key) && key.addToJSMap)
|
||||
key.addToJSMap(ctx, map, value);
|
||||
// TODO: Should drop this special case for bare << handling
|
||||
else if (merge.isMergeKey(ctx, key))
|
||||
merge.addMergeToJSMap(ctx, map, value);
|
||||
else {
|
||||
const jsKey = toJS.toJS(key, '', ctx);
|
||||
if (map instanceof Map) {
|
||||
@@ -43,44 +36,10 @@ function addPairToJSMap(ctx, map, { key, value }) {
|
||||
}
|
||||
return map;
|
||||
}
|
||||
const isMergeKey = (key) => key === MERGE_KEY ||
|
||||
(identity.isScalar(key) &&
|
||||
key.value === MERGE_KEY &&
|
||||
(!key.type || key.type === Scalar.Scalar.PLAIN));
|
||||
// If the value associated with a merge key is a single mapping node, each of
|
||||
// its key/value pairs is inserted into the current mapping, unless the key
|
||||
// already exists in it. If the value associated with the merge key is a
|
||||
// sequence, then this sequence is expected to contain mapping nodes and each
|
||||
// of these nodes is merged in turn according to its order in the sequence.
|
||||
// Keys in mapping nodes earlier in the sequence override keys specified in
|
||||
// later mapping nodes. -- http://yaml.org/type/merge.html
|
||||
function mergeToJSMap(ctx, map, value) {
|
||||
const source = ctx && identity.isAlias(value) ? value.resolve(ctx.doc) : value;
|
||||
if (!identity.isMap(source))
|
||||
throw new Error('Merge sources must be maps or map aliases');
|
||||
const srcMap = source.toJSON(null, ctx, Map);
|
||||
for (const [key, value] of srcMap) {
|
||||
if (map instanceof Map) {
|
||||
if (!map.has(key))
|
||||
map.set(key, value);
|
||||
}
|
||||
else if (map instanceof Set) {
|
||||
map.add(key);
|
||||
}
|
||||
else if (!Object.prototype.hasOwnProperty.call(map, key)) {
|
||||
Object.defineProperty(map, key, {
|
||||
value,
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
function stringifyKey(key, jsKey, ctx) {
|
||||
if (jsKey === null)
|
||||
return '';
|
||||
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
||||
if (typeof jsKey !== 'object')
|
||||
return String(jsKey);
|
||||
if (identity.isNode(key) && ctx?.doc) {
|
||||
|
||||
Reference in New Issue
Block a user