This repository has been archived by the owner on May 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
71 lines (61 loc) · 1.69 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
'use strict';
var gulp = require('gulp'),
nodemon = require('gulp-nodemon'),
mocha = require('gulp-mocha'),
jshint = require('gulp-jshint'),
stylish = require('jshint-stylish'),
util = require('gulp-util'),
_ = require('lodash');
gulp.task('lint', function () {
gulp.src(['plugins/**/*.js', 'index.js', 'gulpfile.js'])
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter(stylish));
});
gulp.task('lint:watch', ['lint'], function(){
gulp.watch(
['plugins/**/*.js', 'index.js'],
function(event){
util.log('file changed:', util.colors.green(event.path));
gulp.src(event.path)
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter(stylish));
}
);
});
gulp.task('test', function () {
gulp.src(['node_modules/image_resizer/test/**/*.js'])
.pipe(mocha({reporter: 'nyan'}))
.on('error', function(err){
console.log(err.toString());
this.emit('end');
});
});
function env(){
var dotenv = require('dotenv'),
fs = require('fs'),
config = {},
file,
home = process.env.HOME;
// useful for storing common AWS credentials with other apps
if ( fs.existsSync(home + '/.awsrc') ){
file = fs.readFileSync(home + '/.awsrc');
_.extend(config, dotenv.parse(file));
}
if ( fs.existsSync('.env') ){
file = fs.readFileSync('.env');
_.extend(config, dotenv.parse(file));
}
// print out the env vars
_.each(config, function(value, key){
util.log('Env:', key, util.colors.cyan(value));
});
return config;
}
gulp.task('watch', ['lint'], function () {
nodemon({
script: 'index.js',
ext: 'js',
env: env(),
ignore: ['node_modules/**/*.js']
}).on('restart', ['lint']);
});