angular/gulp-clang-format

Overwrite code

gurmukhp opened this issue · 4 comments

Instead of providing a formatted directory, is it possible to overwrite the files instead?

Thanks

👍 this seems broken right now.
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

wouldn't this work as a workaround?

gulp.task('format', () => gulp.src(["tools/**/*.ts"]).pipe(format.format('file', clangFormat).pipe(gulp.dest('./tools/'))));

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).

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