diff --git a/.travis.yml b/.travis.yml index 41e7b6efc..2885bbb1c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,14 +4,12 @@ os: - linux - windows node_js: - - '4' - '5' - '6' - 'stable' script: - npm run lint - - npm run test:typings - - npm run test + - npm run test:all cache: directories: - node_modules diff --git a/example/example.js b/example/example.js index 0769e8534..b8c69ba3a 100644 --- a/example/example.js +++ b/example/example.js @@ -6,7 +6,7 @@ ReactDOM.render( React.createElement(DateTime, { viewMode: 'months', dateFormat: 'MMMM', - isValidDate: function(current){ + isValidDate: function(current) { return current.isBefore(DateTime.moment().startOf('month')); } }), diff --git a/example/webpack.config.js b/example/webpack.config.js index a8e608989..d9a62d46e 100644 --- a/example/webpack.config.js +++ b/example/webpack.config.js @@ -1,17 +1,17 @@ var path = require('path'); module.exports = { - entry: [ - 'webpack/hot/dev-server', - 'webpack-dev-server/client?http://localhost:8080', - path.resolve(__dirname, 'example.js') - ], + entry: [ + 'webpack/hot/dev-server', + 'webpack-dev-server/client?http://localhost:8080', + path.resolve(__dirname, 'example.js') + ], - output: { - path: path.resolve(__dirname, '.'), - filename: 'bundle.js' - }, - resolve: { - extensions: ['', '.js'] - } -} + output: { + path: path.resolve(__dirname, '.'), + filename: 'bundle.js' + }, + resolve: { + extensions: ['', '.js'] + } +}; diff --git a/gulpfile.js b/gulpfile.js index 5176a4948..fa3318204 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,13 +1,13 @@ var gulp = require('gulp'), - uglify = require('gulp-uglify'), insert = require('gulp-insert'), + uglify = require('gulp-uglify'), webpack = require('gulp-webpack') ; var packageName = 'react-datetime'; var pack = require( './package.json' ); -var getWPConfig = function( filename ){ +var getWPConfig = function( filename ) { return { externals: { react: 'React', @@ -22,28 +22,28 @@ var getWPConfig = function( filename ){ }; }; -var cr = ('/*\n%%name%% v%%version%%\n%%homepage%%\n%%license%%: https://github.com/arqex/' + packageName + '/raw/master/LICENSE\n*/\n') +var cr = ( '/*\n%%name%% v%%version%%\n%%homepage%%\n%%license%%: https://github.com/arqex/' + packageName + '/raw/master/LICENSE\n*/\n' ) .replace( '%%name%%', pack.name) .replace( '%%version%%', pack.version) .replace( '%%license%%', pack.license) .replace( '%%homepage%%', pack.homepage) ; -var handleError = function( err ){ - console.log( 'Error: ', err ); +var handleError = function( err ) { + console.error( 'Error:', err ); }; -function wp( config, minify ){ - var stream = gulp.src('./Datetime.js') +function wp( config, minify ) { + var stream = gulp.src( './Datetime.js' ) .pipe( webpack( config ) ) ; - if( minify ){ + if( minify ) { stream = stream.pipe( uglify() ).on( 'error', handleError ); } return stream.pipe( insert.prepend( cr ) ) - .pipe( gulp.dest('dist/') ) + .pipe( gulp.dest( 'dist/' ) ) ; } diff --git a/package.json b/package.json index a9a6743a6..458ff6a13 100644 --- a/package.json +++ b/package.json @@ -18,13 +18,14 @@ ], "types": "./typings/index.d.ts", "scripts": { - "build:win": "./node_modules/.bin/gulp.cmd", "build:mac": "./node_modules/.bin/gulp", - "test": "node node_modules/mocha/bin/mocha tests", - "test:watch": "node node_modules/mocha/bin/mocha --watch tests", - "dev": "webpack-dev-server --config example/webpack.config.js --devtool eval --progress --colors --hot --content-base example", + "build:win": "./node_modules/.bin/gulp.cmd", + "dev": "./node_modules/.bin/webpack-dev-server --config example/webpack.config.js --devtool eval --progress --colors --hot --content-base example", "lint": "./node_modules/.bin/eslint src/ DateTime.js", - "test:typings": "tsc -p ./typings" + "test": "node node_modules/mocha/bin/mocha tests", + "test:all": "npm run test:typings && npm run test", + "test:typings": "./node_modules/.bin/tsc -p ./typings", + "test:watch": "node node_modules/mocha/bin/mocha --watch tests" }, "keywords": [ "react", @@ -37,9 +38,9 @@ "author": "Javier Marquez", "license": "MIT", "peerDependencies": { + "moment": ">=2.16.0", "react": ">=0.13", - "react-dom": ">=0.13", - "moment": ">=2.16.0" + "react-dom": ">=0.13" }, "devDependencies": { "@types/react": "^0.14.49", @@ -66,6 +67,6 @@ }, "pre-commit": [ "lint", - "test" + "test:all" ] } diff --git a/tests/testdom.js b/tests/testdom.js index ed640e410..e4696c836 100644 --- a/tests/testdom.js +++ b/tests/testdom.js @@ -1,12 +1,12 @@ -module.exports = function(markup) { - if (typeof document !== 'undefined') return; - var jsdom = require("jsdom").jsdom; - global.document = jsdom(markup || ''); - global.window = document.defaultView; +module.exports = function( markup ) { + if (typeof document !== 'undefined') return; - global.navigator = global.window.navigator = {}; - navigator.userAgent = 'NodeJs JsDom'; - navigator.appVersion = ''; + var jsdom = require('jsdom').jsdom; + global.document = jsdom(markup || ''); + global.window = document.defaultView; + global.navigator = global.window.navigator = {}; + navigator.userAgent = 'NodeJs JsDom'; + navigator.appVersion = ''; - return document; + return document; }; diff --git a/webpack.config.js b/webpack.config.js index c0f00979a..e18a79574 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,7 +2,7 @@ var webpack = require('webpack'); var plugins = [ new webpack.DefinePlugin({ - 'process.env': { NODE_ENV: '"production"'} + 'process.env': { NODE_ENV: '"production"'} }) ];