Simon Egersand
2017-02-05 6f922eca4ecc5fedec9773f3371a0b086b9badc0
Clean up for improved consistency
7 files modified
87 ■■■■ changed files
.travis.yml 4 ●●● patch | view | raw | blame | history
example/example.js 2 ●●● patch | view | raw | blame | history
example/webpack.config.js 26 ●●●● patch | view | raw | blame | history
gulpfile.js 18 ●●●● patch | view | raw | blame | history
package.json 17 ●●●● patch | view | raw | blame | history
tests/testdom.js 18 ●●●● patch | view | raw | blame | history
webpack.config.js 2 ●●● patch | view | raw | blame | history
.travis.yml
@@ -4,14 +4,12 @@
  - 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
example/example.js
@@ -6,7 +6,7 @@
  React.createElement(DateTime, {
    viewMode: 'months',
    dateFormat: 'MMMM',
    isValidDate: function(current){
    isValidDate: function(current) {
      return current.isBefore(DateTime.moment().startOf('month'));
    }
  }),
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']
    }
};
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 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/' ) )
    ;
}
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"
  ]
}
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 || '<!doctype html><html><body></body></html>');
    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 || '<!doctype html><html><body></body></html>');
    global.window             = document.defaultView;
    global.navigator        = global.window.navigator = {};
    navigator.userAgent     = 'NodeJs JsDom';
    navigator.appVersion    = '';
    return document;
    return document;
};
webpack.config.js
@@ -2,7 +2,7 @@
var plugins = [
  new webpack.DefinePlugin({
        'process.env': { NODE_ENV: '"production"'}
      'process.env': { NODE_ENV: '"production"'}
  })
];