Overwrite code
gurmukhp opened this issue · 4 comments
gurmukhp commented
Instead of providing a formatted directory, is it possible to overwrite the files instead?
Thanks
alexeagle commented
I can use gulp.dest('.')
but there is an unfortunate flattening - eg. for angular,
gulp.task('format', () => gulp.src(["tools/**/*.ts"]).pipe(format.format('file', clangFormat).pipe(gulp.dest('.'))));
results in new folders in the project root like broccoli
rather than formatting the files in-place in tools/broccoli
.
cc @mprobst
IgorMinar commented
wouldn't this work as a workaround?
gulp.task('format', () => gulp.src(["tools/**/*.ts"]).pipe(format.format('file', clangFormat).pipe(gulp.dest('./tools/'))));
alexeagle commented
yes, that does work, though it means that for several top-level directories you have several top-level gulp tasks (or a sequence of them).
alexeagle commented
Ah, I'm just missing the base
option to miniglob:
https://github.com/gulpjs/gulp/blob/master/docs/API.md#optionsbase
so it should be
const srcsToFmt = ['tools/**/*.ts'];
gulp.src(srcsToFmt, { base: '.' }).pipe(
format.format('file', clangFormat)).pipe(gulp.dest('.'));
I'll update the docs to resolve this issue