Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

refactor(build): change from grunt to gulp #98

Merged
merged 1 commit into from
Jul 12, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ before_script:
- npm install grunt-cli
- bower install

script: "grunt test:travis"
script: "gulp test"
119 changes: 0 additions & 119 deletions Gruntfile.js

This file was deleted.

25 changes: 12 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,18 @@ Or:
<div ng-bind-html="person.age.toString() | highlight: $select.search"></div>
```

## Run the tests

Install [Node.js](http://nodejs.org/), then inside a console:
```
npm update # Installs all Grunt dependencies (package.json) inside node_modules directory
bower update # Installs all ui-select dependencies (bower.json) inside bower_components directory
```

To run the tests:
```
grunt build # Builds dist/select.js
grunt test # Launches Karma
```
## Development
### Prepare your environment
* Install [Node.js](http://nodejs.org/) and NPM (should come with)
* Install global dev dependencies: `npm install -g bower gulp`
* Install local dev dependencies: `npm install && bower install` in repository directory

### Development Commands

* `gulp` to jshint, build and test
* `gulp build` to jshint and build
* `gulp test` for one-time test with karma (also build and jshint)
* `gulp watch` to watch src files to jshin, build and test when changed

## Contributing

Expand Down
101 changes: 101 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
var fs = require('fs');
var gulp = require('gulp');
var karma = require('karma').server;
var concat = require('gulp-concat');
var jshint = require('gulp-jshint');
var header = require('gulp-header');
var rename = require('gulp-rename');
var es = require('event-stream');
var del = require('del');
var uglify = require('gulp-uglify');
var minifyHtml = require('gulp-minify-html');
var minifyCSS = require('gulp-minify-css');
var templateCache = require('gulp-angular-templatecache');
var gutil = require('gulp-util');
var plumber = require('gulp-plumber');//To prevent pipe breaking caused by errors at 'watch'

var config = {
pkg : JSON.parse(fs.readFileSync('./package.json')),
banner:
'/*!\n' +
' * <%= pkg.name %>\n' +
' * <%= pkg.homepage %>\n' +
' * Version: <%= pkg.version %> - <%= timestamp %>\n' +
' * License: <%= pkg.license %>\n' +
' */\n\n\n'
};

gulp.task('default', ['build','test']);
gulp.task('build', ['scripts', 'styles']);
gulp.task('test', ['build', 'karma']);

gulp.task('watch', ['build','karma-watch'], function() {
gulp.watch(['src/**/*.{js,html}'], ['build']);
});

gulp.task('clean', function(cb) {
del(['dist'], cb);
});

gulp.task('scripts', ['clean'], function() {

var buildTemplates = function () {
return gulp.src('src/**/*.html')
.pipe(minifyHtml({
empty: true,
spare: true,
quotes: true
}))
.pipe(templateCache({module: 'ui.select'}));
};

var buildLib = function(){
return gulp.src('src/select.js')
.pipe(plumber({
errorHandler: handleError
}))
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'));
};

return es.merge(buildLib(), buildTemplates())
.pipe(plumber({
errorHandler: handleError
}))
.pipe(concat('select.js'))
.pipe(header(config.banner, {
timestamp: (new Date()).toISOString(), pkg: config.pkg
}))
.pipe(gulp.dest('dist'))
.pipe(uglify({preserveComments: 'some'}))
.pipe(rename({ext:'.min.js'}))
.pipe(gulp.dest('dist'));

});

gulp.task('styles', ['clean'], function() {

return gulp.src('src/select.css')
.pipe(header(config.banner, {
timestamp: (new Date()).toISOString(), pkg: config.pkg
}))
.pipe(gulp.dest('dist'))
.pipe(minifyCSS())
.pipe(rename({ext:'.min.css'}))
.pipe(gulp.dest('dist'));

});

gulp.task('karma', ['build'], function() {
karma.start({configFile : __dirname +'/karma.conf.js', singleRun: true});
});

gulp.task('karma-watch', ['build'], function() {
karma.start({configFile : __dirname +'/karma.conf.js', singleRun: false});
});

var handleError = function (err) {
console.log(err.toString());
this.emit('end');
};
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module.exports = function(config) {
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers: ['Chrome'],
browsers: [process.env.TRAVIS ? 'Firefox' : 'Chrome'],

// Continuous Integration mode
// if true, it capture browsers, run tests and exit
Expand Down
34 changes: 20 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,26 @@
"version": "0.3.1",
"devDependencies": {
"bower": "~1.3",
"grunt": "~0.4",
"grunt-contrib-clean": "~0.4",
"grunt-contrib-concat": "~0.1",
"grunt-contrib-copy": "~0.5",
"grunt-contrib-cssmin": "^0.10.0",
"grunt-contrib-uglify": "^0.5.0",
"grunt-contrib-watch": "~0.6.1",
"grunt-conventional-changelog": "~1.1",
"grunt-hustler": "~4.0",
"grunt-karma": "~0.8",
"karma": "~0.12",
"karma-chrome-launcher": "~0.1",
"del": "~0.1.1",
"event-stream": "~3.1.0",
"gulp": "~3.8.5",
"gulp-angular-templatecache": "~1.2.1",
"gulp-concat": "~2.1.7",
"gulp-header": "~1.0.2",
"gulp-jshint": "1.6.4",
"gulp-minify-css": "~0.3.6",
"gulp-minify-html": "~0.1.0",
"gulp-plumber": "^0.6.3",
"gulp-rename": "~0.2.2",
"gulp-uglify": "~0.3.1",
"gulp-util": "^2.2.19",
"jshint-stylish": "~0.3.0",
"karma": "^0.12.16",
"karma-chrome-launcher": "^0.1.3",
"karma-firefox-launcher": "~0.1",
"karma-jasmine": "~0.2",
"karma-phantomjs-launcher": "~0.1"
}
"karma-ng-html2js-preprocessor": "^0.1.0",
"karma-phantomjs-launcher": "~0.1.4"
},
"license": "MIT"
}