Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mermal

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mermal - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0

5

dist/bin.js
#!/usr/bin/env node
'use strict';
"use strict";
const program = require('commander');
const ora = require('ora');
const chalk = require('chalk');
const merge = require('./index.js').toFile;

@@ -8,0 +11,0 @@

27

dist/index.js

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,16 +6,21 @@ Object.defineProperty(exports, "__esModule", {

});
exports.toYaml = exports.toJson = exports.toFile = undefined;
exports.toFile = mergeYamlToFile;
exports.toYaml = mergeYamlToYaml;
Object.defineProperty(exports, "toJson", {
enumerable: true,
get: function () {
return _mergeYamlToJson.default;
}
});
var _fs = require('fs');
var _fs = require("fs");
var _jsYaml = require('js-yaml');
var _jsYaml = require("js-yaml");
var _mergeYamlToJson = require('./mergeYamlToJson');
var _mergeYamlToJson = _interopRequireDefault(require("./mergeYamlToJson"));
var _mergeYamlToJson2 = _interopRequireDefault(_mergeYamlToJson);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
async function mergeYamlToYaml(baseYamlPath, searchDirs) {
const finalJson = await (0, _mergeYamlToJson2.default)(baseYamlPath, searchDirs);
const finalJson = await (0, _mergeYamlToJson.default)(baseYamlPath, searchDirs);
return (0, _jsYaml.safeDump)(finalJson);

@@ -27,6 +32,2 @@ }

(0, _fs.writeFileSync)(outFile, finalYaml);
}
exports.toFile = mergeYamlToFile;
exports.toJson = _mergeYamlToJson2.default;
exports.toYaml = mergeYamlToYaml;
}

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,17 +6,14 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
var _jsYaml = require('js-yaml');
var _jsYaml = require("js-yaml");
var _fs = require('fs');
var _fs = require("fs");
var _glob = require('glob');
var _glob = require("glob");
var _lodash = require('lodash.merge');
var _justExtend = _interopRequireDefault(require("just-extend"));
var _lodash2 = _interopRequireDefault(_lodash);
var _justFlattenIt = _interopRequireDefault(require("just-flatten-it"));
var _lodash3 = require('lodash.flattendeep');
var _lodash4 = _interopRequireDefault(_lodash3);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -29,3 +26,3 @@

function getYamlInDirs(dirs) {
return Promise.all(dirs.map(async dir => getYamlInDir(dir))).then(_lodash4.default);
return Promise.all(dirs.map(async dir => getYamlInDir(dir))).then(_justFlattenIt.default);
}

@@ -42,5 +39,4 @@

async function mergeYamlToJson(baseYamlPath, searchDirs) {
const dirs = standardizeDirs(searchDirs);
const dirs = standardizeDirs(searchDirs); // Get the base file
// Get the base file
try {

@@ -51,5 +47,5 @@ const baseJson = loadYaml(baseYamlPath);

const fileContent = loadYaml(file);
(0, _lodash2.default)(baseJson, fileContent);
});
// Get all the sub files
(0, _justExtend.default)(true, baseJson, fileContent);
}); // Get all the sub files
return baseJson;

@@ -59,5 +55,7 @@ } catch (e) {

}
return undefined;
}
exports.default = mergeYamlToJson;
var _default = mergeYamlToJson;
exports.default = _default;

@@ -1,11 +0,9 @@

'use strict';
"use strict";
var _jsYaml = require('js-yaml');
var _jsYaml = require("js-yaml");
var _fs = require('fs');
var _fs = require("fs");
var _ = require('.');
var _ = _interopRequireDefault(require("."));
var _2 = _interopRequireDefault(_);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -34,21 +32,34 @@

test('Handles empty YAML files as empty objects', async () => {
const { baseFilePath, srcDirPath, expected } = loadTestCase('empty');
await expect((0, _2.default)(baseFilePath, srcDirPath)).resolves.toEqual(expected);
const {
baseFilePath,
srcDirPath,
expected
} = loadTestCase('empty');
await expect((0, _.default)(baseFilePath, srcDirPath)).resolves.toEqual(expected);
});
test('Merges two YAML files together', async () => {
const { baseFilePath, srcDirPath, expected } = loadTestCase('simple');
await expect((0, _2.default)(baseFilePath, srcDirPath)).resolves.toEqual(expected);
const {
baseFilePath,
srcDirPath,
expected
} = loadTestCase('simple');
await expect((0, _.default)(baseFilePath, srcDirPath)).resolves.toEqual(expected);
});
test('Merges multiple YAML files together', async () => {
const { baseFilePath, srcDirPath, expected } = loadTestCase('multiple');
await expect((0, _2.default)(baseFilePath, srcDirPath)).resolves.toEqual(expected);
const {
baseFilePath,
srcDirPath,
expected
} = loadTestCase('multiple');
await expect((0, _.default)(baseFilePath, srcDirPath)).resolves.toEqual(expected);
});
test('Merges multiple YAML files, from different directories, together', async () => {
const { baseFilePath, srcDirPath, expected } = loadTestCase('multiple');
const {
baseFilePath,
srcDirPath,
expected
} = loadTestCase('multiple');
const srcDir1 = `${srcDirPath}/articles`;
const srcDir2 = `${srcDirPath}/users`;
await expect((0, _2.default)(baseFilePath, [srcDir1, srcDir2])).resolves.toEqual(expected);
await expect((0, _.default)(baseFilePath, [srcDir1, srcDir2])).resolves.toEqual(expected);
});
{
"name": "mermal",
"description": "Merges YAML files whilst following JSON references",
"version": "0.2.1",
"version": "0.3.0",
"author": "Daniel Li <dan@danyll.com>",

@@ -17,15 +17,15 @@ "bin": {

"glob": "^7.1.3",
"js-yaml": "^3.12.2",
"lodash.flattendeep": "^4.4.0",
"lodash.merge": "^4.6.1",
"js-yaml": "^3.13.0",
"just-extend": "^4.0.2",
"just-flatten-it": "^2.1.0",
"ora": "^3.2.0"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.7.0",
"eslint": "^5.15.1",
"@babel/cli": "^7.2.3",
"@babel/preset-env": "^7.4.2",
"eslint": "^5.15.3",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.16.0",
"husky": "^1.3.1",
"jest": "^24.3.0",
"jest": "^24.5.0",
"synp": "^1.4.0"

@@ -32,0 +32,0 @@ },

import { safeLoad as jsYamlSafeLoad } from 'js-yaml';
import { readFileSync } from 'fs';
import { sync as glob } from 'glob';
import merge from 'lodash.merge';
import flatten from 'lodash.flattendeep';
import extend from 'just-extend';
import flatten from 'just-flatten-it';

@@ -33,3 +33,3 @@ function getYamlInDir(dir) {

const fileContent = loadYaml(file);
merge(baseJson, fileContent);
extend(true, baseJson, fileContent);
});

@@ -36,0 +36,0 @@ // Get all the sub files

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc