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

assemble-yaml

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

assemble-yaml - npm Package Compare versions

Comparing version 0.1.6 to 0.1.7

lib/utils/file.js

9

bower.json
{
"name": "assemble-yaml",
"version": "0.1.6",
"version": "0.1.7",
"repo": "https://github.com/assemble/assemble-yaml.git",

@@ -10,3 +10,8 @@ "main": [

"js-yaml": "~2.1.0",
"lodash": "~1.3.1"
"lodash": "~1.3.1",
"iconv-lite": "~0.2.11",
"chalk": "~0.2.1",
"globule": "~0.1.0",
"to": "~0.2.9",
"sort-object": "0.0.2"
},

@@ -13,0 +18,0 @@ "devDependencies": {

@@ -11,6 +11,20 @@ /*

var yaml = require('js-yaml');
var fs = require('fs');
var _ = require('lodash');
// Node.js
var path = require('path');
var fs = require('fs');
// node_modules
var iconv = require('iconv-lite');
var chalk = require('chalk');
var glob = require('globule');
var yaml = require('js-yaml');
var YAML = require('to').format.yaml;
var _ = require('lodash');
// Local utils.
var file = require('./utils/file');
var sortObject = require('sort-object');
var yamlOptions = ['filename', 'strict', 'schema'];

@@ -32,3 +46,2 @@

var options = _.extend({}, {fromFile: true}, opts);
var data = {

@@ -78,3 +91,3 @@ originalContent: '',

data.content = data.originalContent.substring(eoy + delim.length).replace(/^(\s*)/, '');
data.content = data.originalContent.substring(eoy + delim.length);
return data;

@@ -84,3 +97,51 @@ };

/**
* Add and/or extend YFM with given properties or patterns.
* @param {[type]} dest [description]
* @param {[type]} src [description]
* @param {[type]} options [description]
* @return {[type]} [description]
*/
exports.extend = function(dest, src, options) {
options = options || {};
return glob.find(src, options).map(function (path) {
var context = exports.extract(path, options).context;
context = _.extend({}, options.props, context);
// Optionally sort keys
if(options.sort === true) {
context = YAML.stringify(sortObject(context));
} else {
context = YAML.stringify(context);
}
var content = exports.extract(path, options).content;
return {
path: path,
context: context,
content: content
};
}).map(function (obj) {
function fencedYAML(metadata, content) {
return '---\n' + metadata + '\n---\n' + content;
}
var name = path.basename(obj.path);
var page = fencedYAML(obj.context, obj.content);
file.write(path.join(dest, name), page, function (err) {
if (err) {throw err;}
console.log(chalk.cyan('It\'s saved!'));
});
}).join('\n');
};
/**
* Convenience method for extracting YAML front matter only.

@@ -91,2 +152,3 @@ */

};
exports.readYFM = exports.extractJSON;

@@ -93,0 +155,0 @@

{
"name": "assemble-yaml",
"version": "0.1.6",
"version": "0.1.7",
"description": "Utility library for working with YAML front matter. Works with or without Assemble.",

@@ -48,3 +48,8 @@ "author": {

"js-yaml": "~2.1.0",
"lodash": "~1.3.1"
"lodash": "~1.3.1",
"iconv-lite": "~0.2.11",
"chalk": "~0.2.1",
"globule": "~0.1.0",
"to": "~0.2.9",
"sort-object": "0.0.2"
},

@@ -51,0 +56,0 @@ "keywords": [

@@ -78,4 +78,4 @@ # assemble-yaml [![NPM version](https://badge.fury.io/js/assemble-yaml.png)](http://badge.fury.io/js/assemble-yaml) [![Build Status](https://travis-ci.org/assemble/assemble-yaml.png)](https://travis-ci.org/assemble/assemble-yaml)

* 2013-08-11   v0.1.0   Initial setup - Migrated from main Assemble repo
## Author

@@ -82,0 +82,0 @@

@@ -31,3 +31,3 @@ /*

originalContent: "---\nfoo: bar\nversion: 2\n---\n\n<span class=\"alert alert-info\">This is an alert</span>\n",
content: "<span class=\"alert alert-info\">This is an alert</span>\n"
content: "\n\n<span class=\"alert alert-info\">This is an alert</span>\n"
};

@@ -84,3 +84,3 @@

originalContent: "---\nfoo: bar\nversion: 2\n---\n\n<span class=\"alert alert-info\">This is an alert</span>\n",
content: "<span class=\"alert alert-info\">This is an alert</span>\n"
content: "\n\n<span class=\"alert alert-info\">This is an alert</span>\n"
};

@@ -87,0 +87,0 @@

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