|
|
@ -1,14 +1,14 @@
|
|
|
|
const {src, dest, watch, series, task} = require('gulp');
|
|
|
|
const { src, dest, watch, series, task } = require('gulp')
|
|
|
|
const ts = require('gulp-typescript');
|
|
|
|
const ts = require('gulp-typescript')
|
|
|
|
const del = require('delete');
|
|
|
|
const del = require('delete')
|
|
|
|
const eslint = require('gulp-eslint');
|
|
|
|
const eslint = require('gulp-eslint')
|
|
|
|
const nodemon = require('gulp-nodemon');
|
|
|
|
const nodemon = require('gulp-nodemon')
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Clears the dist folder by deleting all files inside.
|
|
|
|
* Clears the dist folder by deleting all files inside.
|
|
|
|
* @param cb
|
|
|
|
* @param cb
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function clearDist (cb) {
|
|
|
|
function clearDist (cb) {
|
|
|
|
del('dist/*', cb);
|
|
|
|
del('dist/*', cb)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -16,11 +16,11 @@ function clearDist(cb) {
|
|
|
|
* @returns {*}
|
|
|
|
* @returns {*}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function compileTypescript () {
|
|
|
|
function compileTypescript () {
|
|
|
|
let tsProject = ts.createProject('tsconfig.json');
|
|
|
|
const tsProject = ts.createProject('tsconfig.json')
|
|
|
|
let tsResult = tsProject.src().pipe(tsProject());
|
|
|
|
const tsResult = tsProject.src().pipe(tsProject())
|
|
|
|
return tsResult
|
|
|
|
return tsResult
|
|
|
|
// .pipe(minify())
|
|
|
|
// .pipe(minify())
|
|
|
|
.pipe(dest('dist'));
|
|
|
|
.pipe(dest('dist'))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -29,53 +29,55 @@ function compileTypescript() {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function moveRemaining () {
|
|
|
|
function moveRemaining () {
|
|
|
|
return src(['src/**/*', '!src/**/*.ts'])
|
|
|
|
return src(['src/**/*', '!src/**/*.ts'])
|
|
|
|
.pipe(dest('dist'));
|
|
|
|
.pipe(dest('dist'))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function runEslint () {
|
|
|
|
function runEslint () {
|
|
|
|
return src(['scripts/*.js'])
|
|
|
|
return src(['src/**/*.ts'])
|
|
|
|
// eslint() attaches the lint output to the "eslint" property
|
|
|
|
// eslint() attaches the lint output to the "eslint" property
|
|
|
|
// of the file object so it can be used by other modules.
|
|
|
|
// of the file object so it can be used by other modules.
|
|
|
|
.pipe(eslint())
|
|
|
|
.pipe(eslint({ fix: true }))
|
|
|
|
// eslint.format() outputs the lint results to the console.
|
|
|
|
// eslint.format() outputs the lint results to the console.
|
|
|
|
// Alternatively use eslint.formatEach() (see Docs).
|
|
|
|
// Alternatively use eslint.formatEach() (see Docs).
|
|
|
|
.pipe(eslint.format())
|
|
|
|
.pipe(eslint.format())
|
|
|
|
// To have the process exit with an error code (1) on
|
|
|
|
// To have the process exit with an error code (1) on
|
|
|
|
// lint error, return the stream and pipe to failAfterError last.
|
|
|
|
// lint error, return the stream and pipe to failAfterError last.
|
|
|
|
.pipe(eslint.failAfterError());
|
|
|
|
.pipe(eslint.failAfterError())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
task('eslint', () => {
|
|
|
|
task('eslint', () => {
|
|
|
|
return src(['scripts/*.js'])
|
|
|
|
return src(['src/**/*.ts'])
|
|
|
|
// eslint() attaches the lint output to the "eslint" property
|
|
|
|
// eslint() attaches the lint output to the "eslint" property
|
|
|
|
// of the file object so it can be used by other modules.
|
|
|
|
// of the file object so it can be used by other modules.
|
|
|
|
.pipe(eslint())
|
|
|
|
.pipe(eslint({ fix: true }))
|
|
|
|
// eslint.format() outputs the lint results to the console.
|
|
|
|
// eslint.format() outputs the lint results to the console.
|
|
|
|
// Alternatively use eslint.formatEach() (see Docs).
|
|
|
|
// Alternatively use eslint.formatEach() (see Docs).
|
|
|
|
.pipe(eslint.format())
|
|
|
|
.pipe(eslint.format())
|
|
|
|
// To have the process exit with an error code (1) on
|
|
|
|
// To have the process exit with an error code (1) on
|
|
|
|
// lint error, return the stream and pipe to failAfterError last.
|
|
|
|
// lint error, return the stream and pipe to failAfterError last.
|
|
|
|
.pipe(eslint.failAfterError());
|
|
|
|
.pipe(eslint.failAfterError())
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
task('default', series(clearDist, compileTypescript, moveRemaining));
|
|
|
|
task('default', series(clearDist, compileTypescript, moveRemaining))
|
|
|
|
|
|
|
|
|
|
|
|
task('watch', () => {
|
|
|
|
task('watch', () => {
|
|
|
|
watch('**/*.ts', runEslint);
|
|
|
|
runEslint()
|
|
|
|
watch('**/*.ts', compileTypescript);
|
|
|
|
compileTypescript()
|
|
|
|
watch(['src/**/*', '!src/**/*.ts'], moveRemaining());
|
|
|
|
watch('**/*.ts', runEslint)
|
|
|
|
|
|
|
|
watch('**/*.ts', compileTypescript)
|
|
|
|
|
|
|
|
// watch(['src/**/*', '!src/**/*.ts'], moveRemaining());
|
|
|
|
nodemon({
|
|
|
|
nodemon({
|
|
|
|
script: 'dist/index.js',
|
|
|
|
script: 'dist/index.js',
|
|
|
|
watch: ['dist/**/*.js'],
|
|
|
|
watch: ['dist/**/*.js'],
|
|
|
|
ext: 'js'
|
|
|
|
ext: 'js'
|
|
|
|
});
|
|
|
|
})
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
task('watchnolint', () => {
|
|
|
|
task('watchnolint', () => {
|
|
|
|
watch('**/*.ts', compileTypescript);
|
|
|
|
watch('**/*.ts', compileTypescript)
|
|
|
|
watch(['src/**/*', '!src/**/*.ts'], moveRemaining());
|
|
|
|
// watch(['src/**/*', '!src/**/*.ts'], moveRemaining());
|
|
|
|
nodemon({
|
|
|
|
nodemon({
|
|
|
|
script: 'dist/index.js',
|
|
|
|
script: 'dist/index.js',
|
|
|
|
watch: ['dist/**/*.js'],
|
|
|
|
watch: ['dist/**/*.js'],
|
|
|
|
ext: 'js'
|
|
|
|
ext: 'js'
|
|
|
|
});
|
|
|
|
})
|
|
|
|
});
|
|
|
|
})
|
|
|
|