Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 4dd106a

Browse files
author
Nick Litwin
committed
Move tasks to individual files
1 parent fc8994b commit 4dd106a

File tree

10 files changed

+196
-0
lines changed

10 files changed

+196
-0
lines changed

gulp-tasks/clean.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
var del = require('del'); // rm -rf
2+
3+
module.exports = function(gulp, $, config, utilities) {
4+
'use strict';
5+
6+
gulp.task('clean', function(done) {
7+
var delconfig = [].concat(config.build, config.temp);
8+
utilities.log('Cleaning: ' + $.util.colors.blue(delconfig));
9+
del(delconfig, done);
10+
});
11+
gulp.task('clean-fonts', function(done) {
12+
utilities.clean(config.build + 'fonts/**/*.*', done);
13+
});
14+
gulp.task('clean-images', function(done) {
15+
utilities.clean(config.build + 'images/**/*.*', done);
16+
});
17+
gulp.task('clean-styles', function(done) {
18+
utilities.clean(config.temp + '**/*.css', done);
19+
});
20+
};

gulp-tasks/copy-files.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = function(gulp, $, config, utilities) {
2+
'use strict';
3+
4+
gulp.task('copy-html', function() {
5+
utilities.log('Moving app html files to .tmp');
6+
7+
return gulp
8+
.src([config.app + '**/*.html', '!' + config.app + 'specs.html'])
9+
.pipe(gulp.dest(config.temp));
10+
});
11+
};

gulp-tasks/e2e.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = function(gulp, $, config, utilities) {
2+
'use strict';
3+
4+
gulp.task('e2e', function() {
5+
return gulp
6+
.src(['./tests/e2e/app/*.js'])
7+
.pipe($.angularProtractor({
8+
'configFile': 'tests/e2e/conf.js',
9+
'args': ['--baseUrl', 'http://127.0.0.1:8000'],
10+
'autoStartStopServer': true,
11+
'debug': true
12+
}))
13+
.on('error', function(e) { throw e });
14+
});
15+
};

gulp-tasks/fonts.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module.exports = function(gulp, $, config, utilities) {
2+
'use strict';
3+
4+
gulp.task('fonts', ['clean-fonts'], function() {
5+
utilities.log('Copying fonts');
6+
7+
return gulp
8+
.src([config.fonts, 'bower_components/fontawesome/fonts/fontawesome-webfont.*'])
9+
.pipe(gulp.dest(config.build + 'fonts'));
10+
});
11+
12+
// gulp.task('dev-fonts', ['fonts'], function() {
13+
// utilities.log('Copying devicon fonts');
14+
15+
// return gulp
16+
// .src('bower_components/devicon/fonts/**.*')
17+
// .pipe(gulp.dest(config.build + 'styles/fonts'));
18+
// });
19+
};

gulp-tasks/images.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = function(gulp, $, config, utilities) {
2+
'use strict';
3+
4+
5+
};

gulp-tasks/linters.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
var args = require('yargs').argv;
2+
3+
module.exports = function(gulp, $, config, utilities) {
4+
'use strict';
5+
6+
gulp.task('vet', function() {
7+
utilities.log('Analyzing source with JSHint and JSCS');
8+
9+
return gulp
10+
.src(config.alljs)
11+
.pipe($.if(args.verbose, $.print())) // gulp vet --verbose to trigger this line
12+
.pipe($.jscs())
13+
.pipe($.jshint())
14+
.pipe($.jshint.reporter('jshint-stylish', {verbose: true}))
15+
.pipe($.jshint.reporter('fail'));
16+
});
17+
};

gulp-tasks/markup.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
var envFile = require('../config.js')();
2+
var envConfig = envFile[process.env.ENVIRONMENT || 'development'];
3+
4+
module.exports = function(gulp, $, config, utilities) {
5+
'use strict';
6+
7+
gulp.task('jade', function() {
8+
utilities.log('Compiling Jade --> HTML');
9+
10+
return gulp
11+
.src(config.jade)
12+
.pipe($.plumber())
13+
.pipe($.data(function(file) {
14+
return envConfig;
15+
}))
16+
.pipe($.jade({pretty: true}))
17+
.pipe($.replace(/-->/g, ' -->'))
18+
.pipe(gulp.dest(config.temp));
19+
});
20+
};

gulp-tasks/scss.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
var envFile = require('../config.js')();
2+
var envConfig = envFile[process.env.ENVIRONMENT || 'development'];
3+
4+
module.exports = function(gulp, $, config, utilities) {
5+
'use strict';
6+
7+
gulp.task('styles', ['clean-styles'], function() {
8+
utilities.log('Compiling Sass --> CSS');
9+
10+
var assetPrefix = envConfig.CONSTANTS.ASSET_PREFIX.length ? envConfig.CONSTANTS.ASSET_PREFIX : '/';
11+
12+
return gulp
13+
.src(config.sass, {base: './'})
14+
.pipe($.plumber())
15+
.pipe($.sass({includePaths: require('appirio-styles').includePaths}))
16+
.pipe($.autoprefixer({browsers: ['last 2 version']}))
17+
.pipe($.replace(/\/fonts/g, assetPrefix + 'fonts'))
18+
.pipe(gulp.dest(config.temp));
19+
});
20+
21+
gulp.task('sass-watcher', function() {
22+
gulp.watch([config.sass], ['styles']);
23+
});
24+
};

gulp-tasks/template-cache.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = function(gulp, $, config, utilities) {
2+
'use strict';
3+
4+
gulp.task('templatecache', ['clean', 'jade'], function() {
5+
utilities.log('Creating AngularJS $templateCache');
6+
7+
return gulp
8+
.src(config.htmltemplates)
9+
.pipe($.minifyHtml({empty: true}))
10+
.pipe($.angularTemplatecache(
11+
config.templateCache.file,
12+
config.templateCache.options
13+
))
14+
.pipe(gulp.dest(config.temp));
15+
});
16+
};

gulp-tasks/utilities.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
var util = require('gulp-util');
2+
var del = require('del'); // rm -rf
3+
4+
exports.changeEvent = function(event) {
5+
var srcPattern = new RegExp('/.*(?=/' + config.source + ')/');
6+
this.log('File ' + event.path.replace(srcPattern, '') + ' ' + event.type);
7+
}
8+
9+
exports.clean = function(path, done) {
10+
this.log('Cleaning: ' + util.colors.blue(path));
11+
del(path, done);
12+
}
13+
14+
exports.log = function(msg) {
15+
if (typeof(msg) === 'object') {
16+
for (var item in msg) {
17+
if (msg.hasOwnProperty(item)) {
18+
util.log(util.colors.blue(msg[item]));
19+
}
20+
}
21+
} else {
22+
util.log(util.colors.blue(msg));
23+
}
24+
}
25+
26+
exports.startTests = function(singleRun, done) {
27+
var karma = require('karma').server;
28+
var excludeFiles = [];
29+
var serverSpecs = config.serverIntegrationSpecs;
30+
31+
excludeFiles = serverSpecs;
32+
33+
karma.start({
34+
configFile: __dirname + '/karma.conf.js',
35+
exclude: excludeFiles,
36+
singleRun: !!singleRun
37+
}, karmaCompleted);
38+
39+
function karmaCompleted(karmaResult) {
40+
log('Karma completed!');
41+
if (karmaResult === 1) {
42+
done('karma: tests failed with code ' + karmaResult);
43+
} else {
44+
done();
45+
}
46+
}
47+
}
48+
49+
return module.exports;

0 commit comments

Comments
 (0)