Navigation Menu

Skip to content

Commit

Permalink
gulp 构建发生错误时,弹出notify
Browse files Browse the repository at this point in the history
  • Loading branch information
JailBreakC committed Sep 28, 2016
1 parent 8aaf99c commit a97fceb
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -35,3 +35,5 @@ jspm_packages

# Optional REPL history
.node_repl_history

**/.DS_Store
14 changes: 3 additions & 11 deletions app/js/index.js
Expand Up @@ -28,8 +28,6 @@ var gameController = {
gameover: function() {
this.stop();
setTimeout(function() {
// alert('Game Over');
// window.location.reload();
$('#game-ct').hide();
$('.game-over').show();
}.bind(this), 200);
Expand Down Expand Up @@ -182,7 +180,7 @@ var gameController = {
return
}
//碰撞检测
for(i = 0; i < $floor.length; i++) {
for(i = 0; i < $floor.length; i++)
//缓存offset
var floorOffset = $floor.eq(i).offset();
//人物与楼梯纵向距离
Expand All @@ -206,10 +204,6 @@ var gameController = {
peopleOffset.left < floorOffset.left + this._floorWidth ) {
//人物与楼梯偏差修正
this.__currentPeopleY = floorOffset.top - this._peopleHeight;
//立即更新视图
// this.peopleUpdateView();
//让人物随着楼梯共同向上移动(站在楼梯上效果)
// this.__currentPeopleY -= _deltaY;
//施加各类楼梯特殊属性
if($floor.eq(i).hasClass('normal')) {
this.floorNormal();
Expand Down Expand Up @@ -398,7 +392,6 @@ var gameController = {
run: function(fps) {
//不允许执行多个动画渲染函数(你想卡死么...
if(this._animation) {
console.log(this._animation);
console.error('Animation has aready in process, please do not run again!');
return ;
}
Expand All @@ -424,8 +417,6 @@ var gameController = {
$('.floor').remove();
//重新初始化
this.init();
//以每秒60帧执行游戏动画
this.run(60);
},
backup: function() {
//备份初始设置参数,用于游戏reset
Expand Down Expand Up @@ -465,6 +456,8 @@ var gameController = {
this.updateBlood();
//首次更新楼层数
this.updateScore();
//以每秒60帧执行游戏动画
this.run(60);
}
};

Expand All @@ -474,7 +467,6 @@ $(function() {
$('.game-intro').hide();
$('#game-ct').show();
gameController.init();
gameController.run(60);
});

$('#restart-game').click(function() {
Expand Down
2 changes: 1 addition & 1 deletion build/js/index.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 19 additions & 11 deletions gulpfile.js
Expand Up @@ -6,6 +6,8 @@ var gulp = require('gulp'), //基础库
rename = require('gulp-rename'), //重命名
concat = require('gulp-concat'), //合并文件
clean = require('gulp-clean'), //清空文件夹
notify = require('gulp-notify'),
plumber = require('gulp-plumber'),
connect = require('gulp-connect'), //webserver
port = 8888,
rootpath = '';
Expand Down Expand Up @@ -35,28 +37,37 @@ gulp.task('html', function() {
.pipe(gulp.dest(htmlDst))
});

var onError = function(err) {
console.log(err);
notify.onError({
title: "Gulp",
subtitle: "Failure!",
message: "Error: <%= error.message %>",
sound: "Beep"
})(err);
this.emit('end');
};

// 样式处理
gulp.task('css', function () {

gulp.src(cssSrc)
.pipe(plumber({errorHandler: onError}))
.pipe(less({ style: 'expanded'}))
.on( 'error', function(e){console.log(e)} )
.pipe(gulp.dest(cssDst))
.pipe(rename({ suffix: '.min' }))
.pipe(minifycss())
.pipe(connect.reload())
.pipe(gulp.dest(cssMinDst));
.pipe(gulp.dest(cssMinDst))
});

// js处理
gulp.task('js', function () {


gulp.src(jsSrc)
//.pipe(concat('main.js'))
.pipe(rename({ suffix: '.min' }))
.pipe(plumber({errorHandler: onError}))
.pipe(uglify())
.on( 'error', function(e){console.log(e)} )
.pipe(connect.reload())
.pipe(gulp.dest(jsDst));
});
Expand All @@ -75,17 +86,14 @@ gulp.task('rebuild', ['clean'], function(){
// 监听任务 运行语句 gulp watch
gulp.task('default',['webserver'], function(){
// 监听html
gulp.watch(htmlSrc, function(event){
gulp.run('html');
gulp.watch(htmlSrc, ['html'], function(event){
})

// 监听css
gulp.watch(cssSrc, function(){
gulp.run('css');
gulp.watch(cssSrc, ['css'], function(){
});

// 监听js
gulp.watch(jsSrc, function(){
gulp.run('js');
gulp.watch(jsSrc, ['js'], function(){
});
});
2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -28,6 +28,8 @@
"gulp-less": "^3.0.3",
"gulp-livereload": "^3.8.1",
"gulp-minify-css": "^1.2.1",
"gulp-notify": "^2.2.0",
"gulp-plumber": "^1.1.0",
"gulp-rename": "^1.2.2",
"gulp-uglify": "^1.4.1",
"gulp-util": "^3.0.6"
Expand Down
Binary file modified public/.DS_Store
Binary file not shown.

0 comments on commit a97fceb

Please sign in to comment.