forked from marcos-abreu/kamu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
73 lines (61 loc) · 1.81 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
72
'use strict';
var path = require( 'path' ),
gulp = require( 'gulp' ),
plumber = require( 'gulp-plumber' ),
mocha = require( 'gulp-mocha' ),
argv = require( 'yargs' ).argv,
runSequence = require( 'run-sequence' ),
proxyUrl = require( './demo/utils' ).proxyUrl,
config = require( './src/config' );
gulp.task( 'test:unit', function() {
return gulp.src( path.resolve( __dirname, 'test/specs/**/*.spec.js' ), { read: false } )
.pipe( mocha( {
reporter: 'dot',
clearRequireCache: true,
ignoreLeaks: true
} ) );
} );
gulp.task( 'test:integration', function() {
return gulp.src( path.resolve( __dirname, 'test/integration/**/*.js' ), { read: false } )
.pipe( mocha( {
reporter: 'dot',
clearRequireCache: true,
ignoreLeaks: true
} ) );
} );
// gulp.task( 'test', [ 'test:unit', 'test:integration' ] );
gulp.task( 'test', function( done ) {
runSequence( 'test:unit', 'test:integration', done );
} );
gulp.task( 'proxy', function() {
var url = argv.url,
key = argv.key,
bkpKey,
host = argv.host,
bkpHost;
if ( !url ) {
console.log( 'missing required parameter url\n',
'Usage:\n',
' gulp proxy --url=http://www.external-domain.com/path/to/image.png [--key=SOMEKEY] [--host=https://samplehost.com]' );
}
else {
// backup original values and set new ones
if ( key ) {
bkpKey = config.proxyKey;
config.proxyKey = key;
}
if ( host ) {
bkpHost = config.host;
config.host = host;
}
console.log( proxyUrl( url ) );
// revert to original values
if ( key ) {
config.proxyKey = bkpKey;
}
if ( host ) {
config.host = bkpHost;
}
}
return gulp.src( '' );
} );