fabricator-assemble
Advanced tools
Comparing version 1.1.7 to 1.1.8
52
index.js
@@ -32,3 +32,3 @@ // modules | ||
*/ | ||
layouts: 'src/views/layouts/*', | ||
layouts: ['src/views/layouts/*'], | ||
@@ -39,3 +39,3 @@ /** | ||
*/ | ||
layoutIncludes: 'src/views/layouts/includes/*', | ||
layoutIncludes: ['src/views/layouts/includes/*'], | ||
@@ -52,3 +52,3 @@ /** | ||
*/ | ||
materials: 'src/materials/**/*', | ||
materials: ['src/materials/**/*'], | ||
@@ -59,3 +59,3 @@ /** | ||
*/ | ||
data: 'src/data/**/*.{json,yml}', | ||
data: ['src/data/**/*.{json,yml}'], | ||
@@ -66,3 +66,3 @@ /** | ||
*/ | ||
docs: 'src/docs/**/*.md', | ||
docs: ['src/docs/**/*.md'], | ||
@@ -209,3 +209,3 @@ /** | ||
if (options.logErrors) { | ||
console.error(chalk.bold.red('Error (fabricator-assemble): ' + e.message)); | ||
console.error(chalk.bold.red('Error (fabricator-assemble): ' + e.message + '\n'), e.stack); | ||
exit = false; | ||
@@ -216,3 +216,3 @@ } | ||
if (exit) { | ||
console.error(chalk.bold.red('Error (fabricator-assemble): ' + e.message)); | ||
console.error(chalk.bold.red('Error (fabricator-assemble): ' + e.message + '\n'), e.stack); | ||
process.exit(1); | ||
@@ -281,4 +281,5 @@ } | ||
// get all directories | ||
var dirs = files.map(function (file) { | ||
return path.normalize(path.dirname(file)).split(path.sep).pop(); | ||
// do a new glob; trailing slash matches only dirs | ||
var dirs = globby.sync(options.materials + '/').map(function (dir) { | ||
return path.normalize(dir).split(path.sep).slice(-2, -1)[0]; | ||
}); | ||
@@ -290,14 +291,18 @@ | ||
var parent = getName(path.normalize(path.dirname(file)).split(path.sep).slice(-2, -1)[0]); | ||
var collection = getName(path.normalize(path.dirname(file)).split(path.sep).pop()); | ||
var parent = getName(path.normalize(path.dirname(file)).split(path.sep).slice(-2, -1)[0], true); | ||
var collection = getName(path.normalize(path.dirname(file)).split(path.sep).pop(), true); | ||
var isSubCollection = (dirs.indexOf(parent) > -1); | ||
if (!isSubCollection) { | ||
assembly.materials[collection] = assembly.materials[collection] || { | ||
name: toTitleCase(collection), | ||
items: {} | ||
}; | ||
} else { | ||
// get the material base dir for stubbing out the base object for each category (e.g. component, structure) | ||
var materialBase = (isSubCollection) ? parent : collection; | ||
// stub the base object | ||
assembly.materials[materialBase] = assembly.materials[materialBase] || { | ||
name: toTitleCase(getName(materialBase)), | ||
items: {} | ||
}; | ||
if (isSubCollection) { | ||
assembly.materials[parent].items[collection] = assembly.materials[parent].items[collection] || { | ||
name: toTitleCase(collection), | ||
name: toTitleCase(getName(collection)), | ||
items: {} | ||
@@ -315,6 +320,6 @@ }; | ||
var fileMatter = getMatter(file); | ||
var collection = getName(path.normalize(path.dirname(file)).split(path.sep).pop()); | ||
var collection = getName(path.normalize(path.dirname(file)).split(path.sep).pop(), true); | ||
var parent = path.normalize(path.dirname(file)).split(path.sep).slice(-2, -1)[0]; | ||
var isSubCollection = (dirs.indexOf(parent) > -1); | ||
var id = (isSubCollection) ? collection + '.' + getName(file) : getName(file); | ||
var id = (isSubCollection) ? getName(collection) + '.' + getName(file) : getName(file); | ||
var key = (isSubCollection) ? collection + '.' + getName(file, true) : getName(file, true); | ||
@@ -547,3 +552,3 @@ | ||
*/ | ||
Handlebars.registerHelper(inflect.singularize(options.keys.materials), function (name, context, options) { | ||
Handlebars.registerHelper(inflect.singularize(options.keys.materials), function (name, context, opts) { | ||
@@ -566,3 +571,3 @@ // remove leading numbers from name keyword | ||
// return beautified html with trailing whitespace removed | ||
return beautifyHtml(fn(buildContext(context, options.hash)).replace(/^\s+/, ''), options.beautifier); | ||
return beautifyHtml(fn(buildContext(context, opts.hash)).replace(/^\s+/, ''), options.beautifier); | ||
@@ -634,2 +639,5 @@ }); | ||
// change extension to .html | ||
filePath = filePath.replace(/\.[0-9a-z]+$/, '.html'); | ||
// write file | ||
@@ -636,0 +644,0 @@ mkdirp.sync(path.dirname(filePath)); |
{ | ||
"name": "fabricator-assemble", | ||
"version": "1.1.7", | ||
"version": "1.1.8", | ||
"description": "The assembly engine behind Fabricator", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -5,3 +5,3 @@ # Fabricator Assemble | ||
> The assembly engine behind Fabricator | ||
> The assembly engine behind Fabricator. Not associated with [Assemble](http://assemble.io). | ||
@@ -8,0 +8,0 @@ Turn this: |
@@ -17,3 +17,3 @@ var _ = require('lodash'); | ||
views: ['./test/fixtures/views/**/*', '!./test/fixtures/views/+(layouts)/**'], | ||
data: './test/fixtures/data/**/*.{yml,json}', | ||
data: ['./test/fixtures/data/**/*.{yml,json}'], | ||
docs: './test/fixtures/docs/**/*', | ||
@@ -20,0 +20,0 @@ dest: './test/output', |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33775
605