-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
44ce591
commit eb1d6cd
Showing
1 changed file
with
57 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,81 @@ | ||
var gulp = require('gulp'); | ||
var tsc = require('gulp-tsc'); | ||
var shell = require('gulp-shell'); | ||
var runseq = require('run-sequence'); | ||
var gulp = require('gulp'); | ||
var tsc = require('gulp-tsc'); | ||
var shell = require('gulp-shell'); | ||
var tslint = require('gulp-tslint'); | ||
var babel = require('gulp-babel'); | ||
var babel = require('gulp-babel'); | ||
|
||
var paths = { | ||
tscripts : { src : ['src/**/*.ts'], | ||
dest: 'build' | ||
}, | ||
jsscripts: { | ||
src: ['src/**/*.js'], | ||
dest: 'build' | ||
} | ||
tscripts: { src: ['src/**/*.ts'], dest: 'build' }, | ||
jsscripts: { src: ['src/**/*.js'], dest: 'build' }, | ||
}; | ||
|
||
gulp.task('default', ['lint', 'buildrun']); | ||
function defaultTask(cb) { | ||
gulp.series('lint', buildrunTask)(cb); | ||
} | ||
|
||
// ** Running ** // | ||
|
||
gulp.task('run', shell.task([ | ||
'node build/index.js' | ||
])); | ||
function runTask() { | ||
return shell.task([ | ||
'node build/index.js' | ||
]); | ||
} | ||
|
||
gulp.task('buildrun', function (cb) { | ||
runseq('build', 'run', cb); | ||
}); | ||
function buildrunTask(cb) { | ||
gulp.series('build', runTask)(cb); | ||
} | ||
|
||
// ** Watching ** // | ||
|
||
gulp.task('watch', function () { | ||
gulp.watch(paths.tscripts.src, ['compile']); | ||
}); | ||
function watchTask() { | ||
gulp.watch(paths.tscripts.src, compileTask); | ||
} | ||
|
||
gulp.task('watchrun', function () { | ||
gulp.watch(paths.tscripts.src, runseq('compile', 'run')); | ||
}); | ||
function watchrunTask() { | ||
gulp.watch(paths.tscripts.src, gulp.series(compileTask, runTask)); | ||
} | ||
|
||
// ** Compilation ** // | ||
|
||
gulp.task('build', ['compile']); | ||
gulp.task('compile', ['compile:typescript', 'compile:javascript']); | ||
gulp.task('compile:typescript', function () { | ||
function buildTask(cb) { | ||
gulp.series(compileTypescriptTask, compileJavascriptTask)(cb); | ||
} | ||
|
||
function compileTask(cb) { | ||
gulp.series(compileTypescriptTask, compileJavascriptTask)(cb); | ||
} | ||
|
||
function compileTypescriptTask() { | ||
return gulp | ||
.src(paths.tscripts.src) | ||
.pipe(tsc({ | ||
module: "commonjs", | ||
emitError: false | ||
})) | ||
.pipe(gulp.dest(paths.tscripts.dest)); | ||
}); | ||
|
||
gulp.task('compile:javascript', function () { | ||
.src(paths.tscripts.src) | ||
.pipe(tsc({ | ||
module: "commonjs", | ||
emitError: false | ||
})) | ||
.pipe(gulp.dest(paths.tscripts.dest)); | ||
} | ||
|
||
function compileJavascriptTask() { | ||
return gulp | ||
.src(paths.jsscripts.src) | ||
.pipe(babel()) | ||
.pipe(gulp.dest(paths.jsscripts.dest)); | ||
}); | ||
} | ||
|
||
// ** Linting ** // | ||
|
||
gulp.task('lint', ['lint:default']); | ||
gulp.task('lint:default', function(){ | ||
return gulp.src(paths.tscripts.src) | ||
.pipe(tslint()) | ||
.pipe(tslint.report('prose', { | ||
emitError: false | ||
})); | ||
}); | ||
function lintTask() { | ||
return gulp.src(paths.tscripts.src) | ||
.pipe(tslint()) | ||
.pipe(tslint.report('prose', { | ||
emitError: false | ||
})); | ||
} | ||
|
||
exports.default = defaultTask; | ||
exports.lint = lintTask; | ||
exports.compile = compileTask; | ||
exports.build = buildTask; | ||
exports.buildrun = buildrunTask; | ||
exports.watch = watchTask; | ||
exports.watchrun = watchrunTask; |