-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
66 lines (57 loc) · 1.99 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
'use strict';
// IMPORTS
// ================================================================================================
const gulp = require('gulp');
const del = require('del');
const exec = require('child_process').exec;
const mocha = require('gulp-mocha');
const gutil = require('gulp-util');
// TASKS
// ================================================================================================
// delete bin folder
gulp.task('clean', function(cb) {
del(['bin']).then(paths => cb());
});
// compile TypeScript files
gulp.task('compile', ['clean'], function (cb) {
exec('tsc -p .', function (err, stdout, stderr) {
if (stdout.length > 0) console.log(stdout);
if (stderr.length > 0) console.error(stderr);
cb(err);
});
});
// build the project
gulp.task('build', ['compile'], function (cb) {
gulp.src('./package.json').pipe(gulp.dest('./bin'));
gulp.src('./pg-dao.d.ts').pipe(gulp.dest('./bin'));
gulp.src('./.settings/.npmignore').pipe(gulp.dest('./bin'));
gulp.src('./README.md').pipe(gulp.dest('./bin'));
cb();
});
// run tests
gulp.task('test', ['build'], function () {
let argv = process.argv;
let section = '*';
if ( argv[ 3 ] === '--section' ) {
section = argv[ 4 ];
}
return gulp.src( [ `./bin/tests/**/${section}.*.spec.js` ], { read: false } )
.pipe( mocha( { timeout: 5000, bail: false } ) )
.on( 'error', err => {
if ( err && ( !err.message || !err.message.match( /failed/ ) ) ) {
gutil.log( gutil.colors.red( JSON.stringify( err, null, 2 ) ) );
}
} )
.once( 'error', () => process.exit( 1 ) )
.on( 'end', () => process.exit( 0 ) );
});
// publish to npm
gulp.task('publish', ['build'], function (cb) {
exec('npm publish bin --access=public', function (err, stdout, stderr) {
if (stdout.length > 0) console.log(stdout);
if (stderr.length > 0) console.error(stderr);
cb(err);
});
});
// define default task
gulp.task('default', ['build']);