Skip to content

Commit

Permalink
Clean up for improved consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
simeg committed Feb 5, 2017
1 parent e899b61 commit 6f922ec
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 44 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion example/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
}),
Expand Down
26 changes: 13 additions & 13 deletions example/webpack.config.js
Original file line number Diff line number Diff line change
@@ -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']
}
};
18 changes: 9 additions & 9 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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/' ) )
;
}

Expand Down
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -66,6 +67,6 @@
},
"pre-commit": [
"lint",
"test"
"test:all"
]
}
18 changes: 9 additions & 9 deletions tests/testdom.js
Original file line number Diff line number Diff line change
@@ -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;
};
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var webpack = require('webpack');

var plugins = [
new webpack.DefinePlugin({
'process.env': { NODE_ENV: '"production"'}
'process.env': { NODE_ENV: '"production"'}
})
];

Expand Down

0 comments on commit 6f922ec

Please sign in to comment.