metalsmith-layouts
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -0,1 +1,4 @@ | ||
### 2.2.0 - September 4, 2018 | ||
* add suppressNoFilesError feature | ||
### 2.1.0 - January 25, 2018 | ||
@@ -2,0 +5,0 @@ * add a documentation link to the error messages |
@@ -119,3 +119,4 @@ const debug = require('debug')('metalsmith-layouts'); | ||
directory: 'layouts', | ||
engineOptions: {} | ||
engineOptions: {}, | ||
suppressNoFilesError: false | ||
}; | ||
@@ -139,9 +140,12 @@ const settings = Object.assign({}, defaults, options); | ||
// Let the user know when there are no files to process | ||
// Let the user know when there are no files to process, unless the check is suppressed | ||
if (validFiles.length === 0) { | ||
done( | ||
new Error( | ||
'no files to process. See https://www.npmjs.com/package/metalsmith-layouts#no-files-to-process' | ||
) | ||
); | ||
const msg = | ||
'no files to process. See https://www.npmjs.com/package/metalsmith-layouts#no-files-to-process'; | ||
if (settings.suppressNoFilesError) { | ||
debug(msg); | ||
done(); | ||
} else { | ||
done(new Error(msg)); | ||
} | ||
} | ||
@@ -148,0 +152,0 @@ |
@@ -231,2 +231,12 @@ /* eslint-env jest */ | ||
it('should not return an error when there are no valid files to process and suppressNoFilesError is true', done => { | ||
const base = path.join(process.cwd(), 'test', 'fixtures', 'no-files'); | ||
const metalsmith = new Metalsmith(base); | ||
return metalsmith.use(plugin({ suppressNoFilesError: true })).build(err => { | ||
expect(err).toBe(null); | ||
done(); | ||
}); | ||
}); | ||
it('should return an error for an invalid pattern', done => { | ||
@@ -233,0 +243,0 @@ const base = path.join(process.cwd(), 'test', 'fixtures', 'invalid-pattern'); |
@@ -7,4 +7,4 @@ { | ||
"name": "metalsmith-layouts", | ||
"repository": "git://github.com/ismay/metalsmith-layouts.git", | ||
"version": "2.1.0", | ||
"repository": "git://github.com/metalsmith/metalsmith-layouts.git", | ||
"version": "2.2.0", | ||
"scripts": { | ||
@@ -24,4 +24,15 @@ "precommit": "lint-staged", | ||
"ignore": [ | ||
"assert-dir-equal", | ||
"coveralls", | ||
"eslint", | ||
"eslint-plugin-import" | ||
"eslint-config-airbnb-base", | ||
"eslint-config-prettier", | ||
"eslint-plugin-import", | ||
"husky", | ||
"jest", | ||
"jstransformer-handlebars", | ||
"lint-staged", | ||
"metalsmith", | ||
"prettier", | ||
"rimraf" | ||
] | ||
@@ -32,10 +43,10 @@ }, | ||
"coveralls": "^3.0.0", | ||
"eslint": "^4.8.0", | ||
"eslint-config-airbnb-base": "^12.0.2", | ||
"eslint": "^4.19.1", | ||
"eslint-config-airbnb-base": "^13.0.0", | ||
"eslint-config-prettier": "^2.9.0", | ||
"eslint-plugin-import": "^2.7.0", | ||
"eslint-plugin-import": "^2.13.0", | ||
"husky": "^0.14.3", | ||
"jest": "^22.0.4", | ||
"jest": "^23.5.0", | ||
"jstransformer-handlebars": "^1.0.0", | ||
"lint-staged": "^6.0.0", | ||
"lint-staged": "^7.0.0", | ||
"metalsmith": "^2.3.0", | ||
@@ -42,0 +53,0 @@ "prettier": "^1.9.2", |
# metalsmith-layouts | ||
[![npm version][version-badge]][version-url] | ||
[![build status][build-badge]][build-url] | ||
[![coverage status][coverage-badge]][coverage-url] | ||
[![greenkeeper][greenkeeper-badge]][greenkeeper-url] | ||
[![downloads][downloads-badge]][downloads-url] | ||
@@ -13,3 +11,3 @@ > A metalsmith plugin for layouts | ||
The best way to render templates is with [metalsmith-in-place](https://github.com/ismay/metalsmith-in-place) and a templating language that supports inheritance (like [nunjucks](https://mozilla.github.io/nunjucks/templating.html#template-inheritance) or [pug](https://pugjs.org/language/inheritance.html)). That way you'll have a simpler setup that's less error-prone, with support for recursive templating, chained jstransformers and more. So only use this plugin if you have a good reason for wanting to render templates with a language that doesn't support inheritance (like handlebars). | ||
The best way to render templates is with [metalsmith-in-place](https://github.com/metalsmith/metalsmith-in-place) and a templating language that supports inheritance (like [nunjucks](https://mozilla.github.io/nunjucks/templating.html#template-inheritance) or [pug](https://pugjs.org/language/inheritance.html)). That way you'll have a simpler setup that's less error-prone, with support for recursive templating, chained jstransformers and more. So only use this plugin if you have a good reason for wanting to render templates with a language that doesn't support inheritance (like handlebars). | ||
@@ -40,2 +38,3 @@ For support questions please use [stack overflow][stackoverflow-url] or our [slack channel][slack-url]. For templating engine specific questions try the aforementioned channels, as well as the documentation for [jstransformers](https://github.com/jstransformers) and your templating engine of choice. | ||
* [engineOptions](#engineoptions): optional. Use this to pass options to the jstransformer that's rendering your layouts. The default is `{}`. | ||
* [suppressNoFilesError](#suppressnofileserror): optional. An error won’t be thrown if no files are present for processing. | ||
@@ -110,2 +109,8 @@ ### `default` | ||
### `suppressNoFilesError` | ||
`metalsmith-layouts` throws [an error](#no-files-to-process) in metalsmith if it can’t find any files to process. If you’re doing any kind of incremental builds via something like `metalsmith-watch`, this is problematic as you’re likely only rebuilding files that have changed. This flag allows you to suppress that error. | ||
Note that if you have [debugging](#errors-and-debugging) turned on, you’ll see a message denoting when no files are present for processing. | ||
## Example | ||
@@ -226,15 +231,11 @@ | ||
MIT | ||
[MIT](https://ismay.mit-license.org/) | ||
[build-badge]: https://travis-ci.org/ismay/metalsmith-layouts.svg | ||
[build-url]: https://travis-ci.org/ismay/metalsmith-layouts | ||
[greenkeeper-badge]: https://badges.greenkeeper.io/ismay/metalsmith-layouts.svg | ||
[build-badge]: https://travis-ci.org/metalsmith/metalsmith-layouts.svg | ||
[build-url]: https://travis-ci.org/metalsmith/metalsmith-layouts | ||
[greenkeeper-badge]: https://badges.greenkeeper.io/metalsmith/metalsmith-layouts.svg | ||
[greenkeeper-url]: https://greenkeeper.io | ||
[coverage-badge]: https://coveralls.io/repos/github/ismay/metalsmith-layouts/badge.svg?branch=master | ||
[coverage-url]: https://coveralls.io/github/ismay/metalsmith-layouts?branch=master | ||
[downloads-badge]: https://img.shields.io/npm/dm/metalsmith-layouts.svg | ||
[downloads-url]: https://www.npmjs.com/package/metalsmith-layouts | ||
[coverage-badge]: https://coveralls.io/repos/github/metalsmith/metalsmith-layouts/badge.svg?branch=master | ||
[coverage-url]: https://coveralls.io/github/metalsmith/metalsmith-layouts?branch=master | ||
[slack-url]: http://metalsmith-slack.herokuapp.com/ | ||
[stackoverflow-url]: http://stackoverflow.com/questions/tagged/metalsmith | ||
[version-badge]: https://img.shields.io/npm/v/metalsmith-layouts.svg | ||
[version-url]: https://www.npmjs.com/package/metalsmith-layouts |
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
28518
386
238