Skip to content

Commit

Permalink
fix: node 6 support, remove usage of Object.entries (#304)
Browse files Browse the repository at this point in the history
* fix node 6 support, remove usage of Object.entries

* fix unit tests for node 6, clean up window.SSRtest before each test

* change package.json node support

* add node 6 support in travis config

* documentation, change node version support related stuff
  • Loading branch information
Bobgy authored and ScriptedAlchemy committed Oct 14, 2018
1 parent ce780b9 commit 162fc67
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
language: node_js
node_js:
- stable
- 6
cache: yarn
install: yarn --ignore-engines # ignore engines to test node 6, otherwise it fails on engine check
script:
- node_modules/.bin/travis-github-status lint flow jest node_modules/.bin/snyk codeclimate
notifications:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</a>

<a href="https://www.npmjs.com/package/redux-first-router">
<img src=https://img.shields.io/node/v/redux-first-router.svg" alt="Min Node Version: 8" />
<img src="https://img.shields.io/node/v/redux-first-router.svg" alt="Min Node Version: 6" />
</a>

<a href="https://travis-ci.org/faceyspacey/redux-first-router">
Expand Down
4 changes: 4 additions & 0 deletions __tests__/connectRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import { NOT_FOUND } from '../src/index'
import redirect from '../src/action-creators/redirect'
import pathToAction from '../src/pure-utils/pathToAction'

beforeEach(() => {
window.SSRtest = false
})

describe('middleware', () => {
it('dispatches location-aware action, changes address bar + document.title', () => {
const { store, history } = setupAll()
Expand Down
4 changes: 4 additions & 0 deletions __tests__/pure-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import changePageTitle from '../src/pure-utils/changePageTitle'

import { NOT_FOUND } from '../src/index'

beforeEach(() => {
window.SSRtest = false
})

it('isLocationAction(action) if has meta.location object', () => {
let ret = isLocationAction({})
expect(ret).toBeFalsy()
Expand Down
2 changes: 0 additions & 2 deletions docs/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ While RFR2 is a breaking change, its trivial to get up and running again.

Inside of your `configureStore.js` [file](https://github.com/scriptedalchemy/redux-first-router-demo/blob/6c8238eee713ce0079aeae1ce328d305bddd0ee3/src/configureStore.js#L11),

This package requires ***Node 8 and up***

Change this:
```js
const { reducer, middleware, enhancer, thunk } = connectRoutes(
Expand Down
3 changes: 2 additions & 1 deletion docs/redux-persist.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export default {

const parseCookies = (cookies) => {
const parsedCookies = {}
Object.entries(cookies).forEach(([key, value]) => {
Object.keys(cookies).forEach((key) => {
const value = cookies[key]
const decodedKey = decodeURIComponent(key)
const keyWithoutReduxPersistPrefix = decodedKey.replace(/reduxPersist:/, '')
if (key !== 'reduxPersistIndex') { // TODO: This could be expanded into a real black- or whitelist
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "think of your app in states not routes (and, yes, while keeping the address bar in sync)",
"main": "dist/index.js",
"engines": {
"node": ">=8.0.0"
"node": ">=6.0.0"
},
"scripts": {
"build": "babel src -d dist",
Expand Down
3 changes: 2 additions & 1 deletion src/pure-utils/actionToPath.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export default (
}

const _payloadToParams = (route: Route, params: Payload = {}): Params =>
Object.entries(params).reduce((sluggifedParams, [key, segment]) => {
Object.keys(params).reduce((sluggifedParams, key) => {
const segment = params[key]
// $FlowFixMe
sluggifedParams[key] = transformSegment(segment, route, key)
return sluggifedParams
Expand Down

0 comments on commit 162fc67

Please sign in to comment.