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

Commit fd4874b

Browse files
committed
refactor(buid): change from grunt to gulp
1 parent 2483674 commit fd4874b

File tree

6 files changed

+135
-148
lines changed

6 files changed

+135
-148
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ before_script:
88
- npm install grunt-cli
99
- bower install
1010

11-
script: "grunt test:travis"
11+
script: "gulp test"

Gruntfile.js

Lines changed: 0 additions & 119 deletions
This file was deleted.

README.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -138,19 +138,18 @@ Or:
138138
<div ng-bind-html="person.age.toString() | highlight: $select.search"></div>
139139
```
140140

141-
## Run the tests
142-
143-
Install [Node.js](http://nodejs.org/), then inside a console:
144-
```
145-
npm update # Installs all Grunt dependencies (package.json) inside node_modules directory
146-
bower update # Installs all ui-select dependencies (bower.json) inside bower_components directory
147-
```
148-
149-
To run the tests:
150-
```
151-
grunt build # Builds dist/select.js
152-
grunt test # Launches Karma
153-
```
141+
## Development
142+
### Prepare your environment
143+
* Install [Node.js](http://nodejs.org/) and NPM (should come with)
144+
* Install global dev dependencies: `npm install -g bower gulp`
145+
* Install local dev dependencies: `npm install && bower install` in repository directory
146+
147+
### Development Commands
148+
149+
* `gulp` to jshint, build and test
150+
* `gulp build` to jshint and build
151+
* `gulp test` for one-time test with karma (also build and jshint)
152+
* `gulp watch` to watch src files to jshin, build and test when changed
154153

155154
## Contributing
156155

gulpfile.js

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
var fs = require('fs');
2+
var gulp = require('gulp');
3+
var karma = require('karma').server;
4+
var concat = require('gulp-concat');
5+
var jshint = require('gulp-jshint');
6+
var header = require('gulp-header');
7+
var rename = require('gulp-rename');
8+
var es = require('event-stream');
9+
var del = require('del');
10+
var uglify = require('gulp-uglify');
11+
var minifyHtml = require('gulp-minify-html');
12+
var minifyCSS = require('gulp-minify-css');
13+
var templateCache = require('gulp-angular-templatecache');
14+
var gutil = require('gulp-util');
15+
var plumber = require('gulp-plumber');//To prevent pipe breaking caused by errors at 'watch'
16+
17+
var config = {
18+
pkg : JSON.parse(fs.readFileSync('./package.json')),
19+
banner:
20+
'/*!\n' +
21+
' * <%= pkg.name %>\n' +
22+
' * <%= pkg.homepage %>\n' +
23+
' * Version: <%= pkg.version %> - <%= timestamp %>\n' +
24+
' * License: <%= pkg.license %>\n' +
25+
' */\n\n\n'
26+
};
27+
28+
gulp.task('default', ['build','test']);
29+
gulp.task('build', ['scripts', 'styles']);
30+
gulp.task('test', ['build', 'karma']);
31+
32+
gulp.task('watch', ['build','karma-watch'], function() {
33+
gulp.watch(['src/**/*.{js,html}'], ['build']);
34+
});
35+
36+
gulp.task('clean', function(cb) {
37+
del(['dist'], cb);
38+
});
39+
40+
gulp.task('scripts', ['clean'], function() {
41+
42+
var buildTemplates = function () {
43+
return gulp.src('src/**/*.html')
44+
.pipe(minifyHtml({
45+
empty: true,
46+
spare: true,
47+
quotes: true
48+
}))
49+
.pipe(templateCache({module: 'ui.select'}));
50+
};
51+
52+
var buildLib = function(){
53+
return gulp.src('src/select.js')
54+
.pipe(plumber({
55+
errorHandler: handleError
56+
}))
57+
.pipe(jshint())
58+
.pipe(jshint.reporter('jshint-stylish'))
59+
.pipe(jshint.reporter('fail'));
60+
};
61+
62+
return es.merge(buildLib(), buildTemplates())
63+
.pipe(plumber({
64+
errorHandler: handleError
65+
}))
66+
.pipe(concat('select.js'))
67+
.pipe(header(config.banner, {
68+
timestamp: (new Date()).toISOString(), pkg: config.pkg
69+
}))
70+
.pipe(gulp.dest('dist'))
71+
.pipe(uglify({preserveComments: 'some'}))
72+
.pipe(rename({ext:'.min.js'}))
73+
.pipe(gulp.dest('dist'));
74+
75+
});
76+
77+
gulp.task('styles', ['clean'], function() {
78+
79+
return gulp.src('src/select.css')
80+
.pipe(header(config.banner, {
81+
timestamp: (new Date()).toISOString(), pkg: config.pkg
82+
}))
83+
.pipe(gulp.dest('dist'))
84+
.pipe(minifyCSS())
85+
.pipe(rename({ext:'.min.css'}))
86+
.pipe(gulp.dest('dist'));
87+
88+
});
89+
90+
gulp.task('karma', ['build'], function() {
91+
karma.start({configFile : __dirname +'/karma.conf.js', singleRun: true});
92+
});
93+
94+
gulp.task('karma-watch', ['build'], function() {
95+
karma.start({configFile : __dirname +'/karma.conf.js', singleRun: false});
96+
});
97+
98+
var handleError = function (err) {
99+
console.log(err.toString());
100+
this.emit('end');
101+
};

karma.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module.exports = function(config) {
4040
// - Safari (only Mac)
4141
// - PhantomJS
4242
// - IE (only Windows)
43-
browsers: ['Chrome'],
43+
browsers: [process.env.TRAVIS ? 'Firefox' : 'Chrome'],
4444

4545
// Continuous Integration mode
4646
// if true, it capture browsers, run tests and exit

package.json

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,26 @@
88
"version": "0.3.1",
99
"devDependencies": {
1010
"bower": "~1.3",
11-
"grunt": "~0.4",
12-
"grunt-contrib-clean": "~0.4",
13-
"grunt-contrib-concat": "~0.1",
14-
"grunt-contrib-copy": "~0.5",
15-
"grunt-contrib-cssmin": "^0.10.0",
16-
"grunt-contrib-uglify": "^0.5.0",
17-
"grunt-contrib-watch": "~0.6.1",
18-
"grunt-conventional-changelog": "~1.1",
19-
"grunt-hustler": "~4.0",
20-
"grunt-karma": "~0.8",
21-
"karma": "~0.12",
22-
"karma-chrome-launcher": "~0.1",
11+
"del": "~0.1.1",
12+
"event-stream": "~3.1.0",
13+
"gulp": "~3.8.5",
14+
"gulp-angular-templatecache": "~1.2.1",
15+
"gulp-concat": "~2.1.7",
16+
"gulp-header": "~1.0.2",
17+
"gulp-jshint": "1.6.4",
18+
"gulp-minify-css": "~0.3.6",
19+
"gulp-minify-html": "~0.1.0",
20+
"gulp-plumber": "^0.6.3",
21+
"gulp-rename": "~0.2.2",
22+
"gulp-uglify": "~0.3.1",
23+
"gulp-util": "^2.2.19",
24+
"jshint-stylish": "~0.3.0",
25+
"karma": "^0.12.16",
26+
"karma-chrome-launcher": "^0.1.3",
2327
"karma-firefox-launcher": "~0.1",
2428
"karma-jasmine": "~0.2",
25-
"karma-phantomjs-launcher": "~0.1"
26-
}
29+
"karma-ng-html2js-preprocessor": "^0.1.0",
30+
"karma-phantomjs-launcher": "~0.1.4"
31+
},
32+
"license": "MIT"
2733
}

0 commit comments

Comments
 (0)