-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Showing
1 changed file
with
89 additions
and
89 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,89 +1,89 @@ | ||
var gulp = require('gulp'), | ||
bump = require('gulp-bump'), | ||
git = require('gulp-git'), | ||
inject = require('gulp-inject-string'), | ||
merge = require('merge-stream'), | ||
tag_version = require('gulp-tag-version'), | ||
tslint = require('gulp-tslint'), | ||
typings = require('gulp-typings'), | ||
shell = require('gulp-shell'); | ||
exec = require('child_process').exec; | ||
|
||
var paths = { | ||
src_ts: 'src/**/*.ts', | ||
tests_ts: 'test/**/*.ts', | ||
}; | ||
|
||
function versionBump(semver) { | ||
return gulp | ||
.src(['./package.json']) | ||
.pipe(bump({ type: semver })) | ||
.pipe(gulp.dest('./')) | ||
.pipe(git.commit('bump package version')) | ||
.pipe(tag_version()); | ||
} | ||
|
||
gulp.task('typings', function() { | ||
return gulp.src('./typings.json').pipe(typings()); | ||
}); | ||
|
||
gulp.task('typings-vscode-definitions', ['typings'], function() { | ||
// add vscode definitions | ||
return gulp.src('./typings/index.d.ts').pipe(gulp.dest('./typings')); | ||
}); | ||
|
||
gulp.task('tslint', function() { | ||
var tslintOptions = { | ||
summarizeFailureOutput: true, | ||
}; | ||
|
||
var srcs = gulp | ||
.src(paths.src_ts) | ||
.pipe(tslint({ formatter: 'verbose' })) | ||
.pipe(tslint.report(tslintOptions)); | ||
var tests = gulp | ||
.src(paths.tests_ts) | ||
.pipe(tslint({ formatter: 'verbose' })) | ||
.pipe(tslint.report(tslintOptions)); | ||
return merge(srcs, tests); | ||
}); | ||
|
||
gulp.task('prettier', function() { | ||
runPrettier('git diff --name-only HEAD'); | ||
}); | ||
|
||
gulp.task('forceprettier', function() { | ||
// Enumerate files managed by git | ||
runPrettier('git ls-files'); | ||
// Enumerate untracked files | ||
runPrettier('git ls-files --others --exclude-standard'); | ||
}); | ||
|
||
function runPrettier(command) { | ||
exec(command, function(err, stdout, stderr) { | ||
const files = stdout.split('\n'); | ||
for (const file of files) { | ||
if (file.endsWith('.ts') || file.endsWith('.js')) { | ||
exec( | ||
`node ./node_modules/prettier/bin/prettier.js --write --print-width 100 --single-quote --trailing-comma es5 ${file}` | ||
); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
gulp.task('default', ['prettier', 'tslint', 'compile']); | ||
|
||
gulp.task('compile', shell.task(['npm run vscode:prepublish'])); | ||
gulp.task('watch', shell.task(['npm run compile'])); | ||
gulp.task('init', ['typings', 'typings-vscode-definitions']); | ||
|
||
gulp.task('patch', ['default'], function() { | ||
return versionBump('patch'); | ||
}); | ||
gulp.task('minor', ['default'], function() { | ||
return versionBump('minor'); | ||
}); | ||
gulp.task('major', ['default'], function() { | ||
return versionBump('major'); | ||
}); | ||
var gulp = require('gulp'), | ||
bump = require('gulp-bump'), | ||
git = require('gulp-git'), | ||
inject = require('gulp-inject-string'), | ||
merge = require('merge-stream'), | ||
tag_version = require('gulp-tag-version'), | ||
tslint = require('gulp-tslint'), | ||
typings = require('gulp-typings'), | ||
shell = require('gulp-shell'), | ||
exec = require('child_process').exec; | ||
|
||
var paths = { | ||
src_ts: 'src/**/*.ts', | ||
tests_ts: 'test/**/*.ts', | ||
}; | ||
|
||
function versionBump(semver) { | ||
return gulp | ||
.src(['./package.json']) | ||
.pipe(bump({ type: semver })) | ||
.pipe(gulp.dest('./')) | ||
.pipe(git.commit('bump package version')) | ||
.pipe(tag_version()); | ||
} | ||
|
||
gulp.task('typings', function() { | ||
return gulp.src('./typings.json').pipe(typings()); | ||
}); | ||
|
||
gulp.task('typings-vscode-definitions', ['typings'], function() { | ||
// add vscode definitions | ||
return gulp.src('./typings/index.d.ts').pipe(gulp.dest('./typings')); | ||
}); | ||
|
||
gulp.task('tslint', function() { | ||
var tslintOptions = { | ||
summarizeFailureOutput: true, | ||
}; | ||
|
||
var srcs = gulp | ||
.src(paths.src_ts) | ||
.pipe(tslint({ formatter: 'verbose' })) | ||
.pipe(tslint.report(tslintOptions)); | ||
var tests = gulp | ||
.src(paths.tests_ts) | ||
.pipe(tslint({ formatter: 'verbose' })) | ||
.pipe(tslint.report(tslintOptions)); | ||
return merge(srcs, tests); | ||
}); | ||
|
||
gulp.task('prettier', function() { | ||
runPrettier('git diff --name-only HEAD'); | ||
}); | ||
|
||
gulp.task('forceprettier', function() { | ||
// Enumerate files managed by git | ||
runPrettier('git ls-files'); | ||
// Enumerate untracked files | ||
runPrettier('git ls-files --others --exclude-standard'); | ||
}); | ||
|
||
function runPrettier(command) { | ||
exec(command, function(err, stdout, stderr) { | ||
const files = stdout.split('\n'); | ||
for (const file of files) { | ||
if (file.endsWith('.ts') || file.endsWith('.js')) { | ||
exec( | ||
`node ./node_modules/prettier/bin/prettier.js --write --print-width 100 --single-quote --trailing-comma es5 ${file}` | ||
); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
gulp.task('default', ['prettier', 'tslint', 'compile']); | ||
|
||
gulp.task('compile', shell.task(['npm run vscode:prepublish'])); | ||
gulp.task('watch', shell.task(['npm run compile'])); | ||
gulp.task('init', ['typings', 'typings-vscode-definitions']); | ||
|
||
gulp.task('patch', ['default'], function() { | ||
return versionBump('patch'); | ||
}); | ||
gulp.task('minor', ['default'], function() { | ||
return versionBump('minor'); | ||
}); | ||
gulp.task('major', ['default'], function() { | ||
return versionBump('major'); | ||
}); |