Skip to content

Commit

Permalink
BREAKING: Support only node 6 and 7. Updated CI config
Browse files Browse the repository at this point in the history
The introduction of source-locators breaks compatibility with
node-versions below 6, because the package 'handlebars-source-locators'
uses language features that are only available in node 6.

In addition, this commit introduces minor changes in the Travis-
configuration:

- "standard" is now a dev-dependency to enable controlled updates
  through Greenkeeper
- "thougth -d up-to-date" is run in Travis-CI to make sure the
  documentation is up-to-date
- Examples are not executed with a custom `console.log`-function
  that uses "json-stable-stringify" to create a stable output. This
  has been done because "`"thought up-to-date" compares the checked-in
  documentation to the documentation that would be generated right now.
  This requires the output of examples to be stable.
- Reduce load on traffic by executing Thought and Standard in their own
  build job (and not for each node version)
- Add caching-options to .travis.yml
- Run standard as precommit hook rathern than pre-push, because
  the check then always refers to the active branch.
- Run "standard --fix" on precommit rather than just "standard", because
  it is require most of the time, when "standard" fails.
  • Loading branch information
nknapp committed Mar 14, 2017
1 parent ff0adfa commit c639b39
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 20 deletions.
14 changes: 7 additions & 7 deletions .thought/partials/usage.md.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Usage

The following example demonstrates how to use this module:
The following examples demonstrate how to use this module. The following files are involved:

{{{dirTree 'examples/' }}}

Expand All @@ -11,11 +11,11 @@ of the Handlebars-engine:

{{{example 'examples/example.js'}}}

This example loads its configuration from the module `config-module.js`
This example loads its configuration from the module `config-module.js`:

{{{include 'examples/config-module.js'}}}

*A quick note: If your are really creating a configuration-module, you should always
*A quick note: If your are creating a real configuration-module, you should always
use `require.resolve` or `__dirname` to determine the correct path to referenced files.*

All the templates in the `templates` directory are called with the provided `data` (name and city).
Expand All @@ -39,7 +39,7 @@ the `footer.hbs` partial.

The output of this example is:

{{{exec 'node example.js' cwd='examples/'}}}
{{{exec 'node -r "../.thought/stable-console" example.js' cwd='examples/'}}}


### Customizing configurations
Expand All @@ -57,7 +57,7 @@ The new `footer.hbs` writes only the current temperature, instead of the weather

The output of this example is

{{{exec 'node example-merge.js' cwd='examples/'}}}
{{{exec 'node -r "../.thought/stable-console" example-merge.js' cwd='examples/'}}}

In a similar fashion, we could replace other parts of the configuration, like templates, helpers
and the pre-processor. If we would provide a new preprocessor, it could call the old one,
Expand All @@ -74,7 +74,7 @@ to override in order to modify a given part of the output.

{{{example 'examples/example-partial-names.js'}}}

{{{exec 'node example-partial-names.js' cwd='examples/'}}}
{{{exec 'node -r "../.thought/stable-console" example-partial-names.js' cwd='examples/'}}}

### Which partial generates what? (Method 2)

Expand All @@ -92,7 +92,7 @@ The output contain tags that contain location-information of the succeeding text

Example output:

{{{exec 'node example-source-locators.js' cwd='examples/'}}}
{{{exec 'node -r "../.thought/stable-console" example-source-locators.js' cwd='examples/'}}}



Expand Down
11 changes: 11 additions & 0 deletions .thought/stable-console.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// For the examples, make sure that the output is stable
var consoleLog = console.log
var stringify = require('json-stable-stringify')

console.log = function () {
consoleLog.apply(this, Array.prototype.map.call(
arguments, (arg) => JSON.parse(stringify(arg, { space: 2 }))
))
}


22 changes: 15 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
sudo: false
cache:
directories:
- node_modules
language: "node_js"
node_js:
- "0.10"
- "0.12"
- "iojs"
- "4"
- "6"
- "7"
before_script:
- npm install standard
- standard
matrix:
include:
- node_js: "6"
env: STATIC_CHECKS=true
script:
- |
if [ "${STATIC_CHECKS}" = "true" ]; then
# Just perform static checks and exit
standard || exit 1
npm install thought
thought -d up-to-date || exit 1
exit 0
fi
- npm install istanbul
- istanbul cover ./node_modules/.bin/_mocha --report lcovonly
after_script:
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# customize-engine-handlebars

[![Greenkeeper badge](https://badges.greenkeeper.io/bootprint/customize-engine-handlebars.svg)](https://greenkeeper.io/)

[![NPM version](https://badge.fury.io/js/customize-engine-handlebars.svg)](http://badge.fury.io/js/customize-engine-handlebars)
[![Travis Build Status](https://travis-ci.org/bootprint/customize-engine-handlebars.svg?branch=master)](https://travis-ci.org/bootprint/customize-engine-handlebars)
[![Coverage Status](https://img.shields.io/coveralls/bootprint/customize-engine-handlebars.svg)](https://coveralls.io/r/bootprint/customize-engine-handlebars)
Expand All @@ -18,7 +16,7 @@ npm install customize-engine-handlebars

## Usage

The following example demonstrates how to use this module:
The following examples demonstrate how to use this module. The following files are involved:

<pre><code>

Expand Down Expand Up @@ -52,7 +50,7 @@ customize()
.done(console.log)
```

This example loads its configuration from the module `config-module.js`
This example loads its configuration from the module `config-module.js`:

```js
module.exports = function (customize) {
Expand All @@ -78,7 +76,7 @@ module.exports = function (customize) {
```


*A quick note: If your are really creating a configuration-module, you should always
*A quick note: If your are creating a real configuration-module, you should always
use `require.resolve` or `__dirname` to determine the correct path to referenced files.*

All the templates in the `templates` directory are called with the provided `data` (name and city).
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
"customize": "^1.0.0",
"get-promise": "^1.4.0",
"ghooks": "^2.0.0",
"json-stable-stringify": "^1.0.1",
"mocha": "^3.2.0",
"standard": "^9.0.1",
"thoughtful-release": "^0.3.0",
"trace-and-clarify-if-possible": "^1.0.0"
},
Expand All @@ -61,7 +63,7 @@
],
"config": {
"ghooks": {
"pre-push": "thoughtful precommit && standard"
"pre-commit": "thoughtful precommit && standard --fix"
}
},
"keywords": []
Expand Down

0 comments on commit c639b39

Please sign in to comment.