diff --git a/.gitignore b/.gitignore index 8801a82..290b8b7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ *.log .DS_Store -dist +es5 node_modules diff --git a/.travis.yml b/.travis.yml index 3f308e8..a00fbac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ language: node_js node_js: + - "0.10" + - "0.12" - "4" - "5" - "6" diff --git a/index.test.js b/index.test.js index 601ed41..7371fc4 100644 --- a/index.test.js +++ b/index.test.js @@ -1,6 +1,12 @@ +/* eslint-disable vars-on-top, global-require */ + var assert = require('chai').assert; -var TestServer = require('.'); +if (typeof Promise === 'undefined') { + global.Promise = require('native-promise-only'); +} + +var TestServer = require('./index'); // very simple http handler var app = (req, res) => { diff --git a/package.json b/package.json index da2644c..d32d69e 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,11 @@ "description": "Test node.js HTTP servers using the fetch API", "main": "index.js", "scripts": { + "build": "rm -r es5 > /dev/null; babel ./*.js -d es5", + "prepublish": "npm run build", "lint": "eslint *.js", - "mocha": "mocha *.test.js", - "test": "npm run lint && npm run mocha" + "mocha": "[ `echo $npm_config_node_version | cut -d. -f1` -eq 0 ] && mocha es5/*.test.js || mocha *.test.js", + "test": "npm run lint && npm run build && npm run mocha" }, "repository": { "type": "git", @@ -33,10 +35,26 @@ "node-fetch": "^1.5.1" }, "devDependencies": { + "babel-cli": "^6.7.7", + "babel-plugin-transform-es2015-arrow-functions": "^6.7.7", + "babel-plugin-transform-es2015-template-literals": "^6.6.5", + "babel-plugin-transform-object-assign": "^6.5.0", "chai": "3.5.0", "eslint": "2.8.0", "eslint-config-airbnb-base": "1.0.4", "eslint-plugin-import": "1.6.0", - "mocha": "2.4.5" + "mocha": "2.4.5", + "native-promise-only": "^0.8.1" + }, + "files": [ + "es5", + "*.js" + ], + "babel": { + "plugins": [ + "transform-es2015-arrow-functions", + "transform-es2015-template-literals", + "transform-object-assign" + ] } }