From 0a205f5e8a6eed8bc6159ff5a42a3fca9e1ccd54 Mon Sep 17 00:00:00 2001 From: Michael Barrett Date: Thu, 30 Apr 2015 11:37:57 +0100 Subject: [PATCH] use gulp instead of grunt --- .gitignore | 1 - .jscsrc | 2 ++ .npmignore | 3 ++- .travis.yml | 7 +------ Gruntfile.js | 43 ----------------------------------------- Gulpfile.js | 44 ++++++++++++++++++++++++++++++++++++++++++ bower.json | 2 +- dist/timestring.min.js | 3 ++- package.json | 20 +++++++++++-------- 9 files changed, 64 insertions(+), 61 deletions(-) create mode 100644 .jscsrc delete mode 100644 Gruntfile.js create mode 100644 Gulpfile.js diff --git a/.gitignore b/.gitignore index d49756d..2ccbe46 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ /node_modules/ -/build/ diff --git a/.jscsrc b/.jscsrc new file mode 100644 index 0000000..2c63c08 --- /dev/null +++ b/.jscsrc @@ -0,0 +1,2 @@ +{ +} diff --git a/.npmignore b/.npmignore index 8878e43..383af84 100644 --- a/.npmignore +++ b/.npmignore @@ -1,10 +1,11 @@ .editorconfig .gitignore .jshintrc +.jscsrc .travis.yml bower.json CHANGELOG.md -Gruntfile.js +Gulpfile.js LICENSE README.md /test/ diff --git a/.travis.yml b/.travis.yml index 43a800f..45074de 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,6 @@ language: node_js node_js: - - "0.6" - - "0.8" - "0.10" - "0.11" - "0.12" @@ -15,7 +13,4 @@ cache: directories: - node_modules -before_script: - - npm install -g grunt-cli - -script: grunt test +script: gulp ci diff --git a/Gruntfile.js b/Gruntfile.js deleted file mode 100644 index fa92324..0000000 --- a/Gruntfile.js +++ /dev/null @@ -1,43 +0,0 @@ -module.exports = function(grunt) { - // measure the time each task takes - require('time-grunt')(grunt); - - // autoload Grunt tasks - require('load-grunt-tasks')(grunt); - - // main project config - grunt.initConfig({ - pkg: grunt.file.readJSON('package.json'), - uglify: { - dist: { - files: { - 'dist/<%= pkg.name %>.min.js': 'src/<%= pkg.name %>.js' - } - } - }, - jshint: { - options: { - jshintrc: true - }, - files: [ - 'Gruntfile.js', - 'src/<%= pkg.name %>.js', - 'test/**/*.js' - ] - }, - mochaTest: { - test: { - options: { - reporter: 'spec' - }, - src: ['test/**/*.js'] - } - } - }); - - // user defined tasks - grunt.registerTask('test', ['mochaTest']); - grunt.registerTask('lint', ['jshint']); - grunt.registerTask('build', ['uglify']); - grunt.registerTask('default', ['jshint', 'mochaTest', 'uglify']); -}; diff --git a/Gulpfile.js b/Gulpfile.js new file mode 100644 index 0000000..af67ad4 --- /dev/null +++ b/Gulpfile.js @@ -0,0 +1,44 @@ +var gulp = require('gulp'); +var $ = require('gulp-load-plugins')({ + scope: 'devDependencies' +}); +var runSequence = require('run-sequence'); + +gulp.task('lint', function () { + gulp.src('src/**/*.js') + .pipe($.jshint('.jshintrc')) + .pipe($.jshint.reporter('jshint-stylish')); +}); + +gulp.task('cs', function () { + return gulp.src('src/**/*.js') + .pipe($.jscs()); +}); + +gulp.task('test', function () { + return gulp.src('test/**/*.js', { read: false }) + .pipe($.mocha()); +}); + +gulp.task('minify', function () { + return gulp.src('src/*.js') + .pipe($.sourcemaps.init()) + .pipe($.uglify()) + .pipe($.rename({ + extname: '.min.js' + })) + .pipe($.sourcemaps.write()) + .pipe(gulp.dest('dist')); +}); + +gulp.task('build', function (callback) { + runSequence( + ['lint', 'cs', 'test'], + 'minify', + callback + ); +}); + +gulp.task('ci', ['lint', 'cs', 'test']); + +gulp.task('default', ['build']); diff --git a/bower.json b/bower.json index 7215346..63d2a82 100644 --- a/bower.json +++ b/bower.json @@ -11,7 +11,7 @@ "ignore": [ "**/.*", "CHANGELOG.md", - "Gruntfile.js", + "Gulpfile.js", "LICENSE", "README.md", "node_modules", diff --git a/dist/timestring.min.js b/dist/timestring.min.js index 470b3d1..06f5beb 100644 --- a/dist/timestring.min.js +++ b/dist/timestring.min.js @@ -1 +1,2 @@ -(function(){"use strict";var a=function(a){var b={hoursPerDay:24,daysPerWeek:7,weeksPerMonth:4,monthsPerYear:12};a=a||{},this.settings=b;for(var c in a)this.settings[c]=a[c];this.units={s:["s","sec","secs","second","seconds"],m:["m","min","mins","minute","minutes"],h:["h","hr","hrs","hour","hours"],d:["d","day","days"],w:["w","week","weeks"],mth:["mth","mths","month","months"],y:["y","yr","yrs","year","years"]},this.unitValues={s:1,m:60,h:3600},this.unitValues.d=this.settings.hoursPerDay*this.unitValues.h,this.unitValues.w=this.settings.daysPerWeek*this.unitValues.d,this.unitValues.mth=this.settings.weeksPerMonth*this.unitValues.w,this.unitValues.y=this.settings.monthsPerYear*this.unitValues.mth};a.prototype.parse=function(a,b){function c(a){for(var b in f.units)for(var c in f.units[b])if(a===f.units[b][c])return b;throw new Error("The unit ["+a+"] is not supported by timestring")}function d(a,b){var d=f.unitValues[c(b)];return a/d}function e(a,b){var d=f.unitValues[c(b)];return a*d}var f=this,g=0,h=a.toLowerCase().replace(/[^\.\w+-]+/g,"").match(/[-+]?[0-9]+[a-z]+/g);if(null!==h)for(var i=0;i