gulp


Can't get gulp-jscs to write fixed files over originals


No problems running the gulp-jscs plugin to analyze my code using the following task. However when I add fix:true, nothing changes in the files and JSCS now acts like it isn't running at all... when I remove the object passed into the JSCS plugin and remove the gulp.dest() line, it will report code style issues.
So, it seems either passing in the fix:true or tying to write back the fixed files causes JSCS to short circuit internally... ideas?
var $ = require('gulp-load-plugins')({lazy: true});
gulp.task('vet', function () {
log('Analyzing source with JSHint and JSCS');
return gulp
.src(config.allJs, {base: './'})
.pipe($.jshint())
.pipe($.jshint.reporter('jshint-stylish', {verbose: true}))
.pipe($.jscs({fix:true}))
.pipe(gulp.dest('./'));
});
Update 2
I have found a simpler/cleaner way to do, just specify the base parameter
gulp.src(files, {base: './'})
then file.name will contain the full path so you can output to the current directory
gulp.dest('.')
so at the end:
gulp.src(files, {base: './'})
.pipe(jscs({fix: true}))
.pipe(jscs.reporter())
.pipe(jscs.reporter('fail'))
.pipe(gulp.dest('.'))
.on('error', console.error.bind(console));
Update 1
I have been tackling this problem with this piece of code:
var gulp = require('gulp');
var jscs = require('gulp-jscs');
var foreach = require('gulp-foreach');
var rimraf = require('gulp-rimraf');
gulp.task('jscs', () => {
return gulp.src(['file1.js', 'file2.js'])
.pipe(foreach((stream, file) => {
return stream
.pipe(jscs({ fix: true }))
.pipe(jscs.reporter())
//.pipe(jscs.reporter('fail'))
.pipe(rimraf())
.pipe(gulp.dest(file.base));
}));
});
dependencies:
npm install --save-dev gulp gulp-rimraf gulp-foreach gulp-jscs
Globally, gulp-foreach iterates over every src with its own stream, rimraf delete the file before writing on vinyl.base destination.
Let me know if it helps.

Related Links

gulp-webserver: Default to index.html if available, else show directories
gulp-uglify notify on failing build
Declaring optional dependencies
gulp html minification error
Can an IIFE be added to a browserify bundle?
Gulp: Error Messages and Notifications with Plumber
Gulp - gulp-load-plugins not working
How to configure Gulp task to copy bower resources
gulp-jscs doesn't output anything when used in gulp-watch pipeline
ES6 project does not compile because modules not found
Gulp - can't set multiple relative destinations
Deploy a Yeoman Application With Gulp
Gulp-Inject Positions
Fail subsequent gulp tasks if first task fails
Why “gulp-jest” is failing with: “Please run node with the --harmony flag!”?
Understanding gulp-reactify workflow/structure

Categories

HOME
spring-boot
postgresql
azure-active-directory
system-calls
window.open
popover
glsl
django-middleware
ubuntu-14.04
thermal-printer
aggregation-framework
kendo-asp.net-mvc
dcos
jpql
urllib2
sha1
exchange-transport-agents
project-reactor
summernote
computation-theory
multipart
rndis
ecmascript-2017
ithit-webdav-server
sha
grunt-contrib-uglify
sasl
utc
cloudformation
request-uri
delphi-2010
edirectory
key-bindings
jcr
circle
ilog
restler
intersection
sdl-2
usernotifications
cowboy
delphi-xe
flume-ng
uitextview
qt-quick
nshttpurlresponse
serverless-architecture
beanshell
riemann
htop
jtextarea
codesniffer
scanf
fileopendialog
timefield
mavlink
falcon
airwatch
queuing
window.location
video-embedding
hana-sql-script
skscene
android-facebook
mojolicious
webservices-client
transbase
self-join
om
dnvm
euro
clearquest
autopep8
touch-typing
diffmerge
conditional-comments
serializer
msdropdown
nodeunit
fastcgi-mono-server
kernel-density
windows-phone-store
ardor3d
mencoder
kendo-window
objectdatasource
backbone-views
netbiscuits
databus
optimistic-concurrency
cherokee
parallel-python
overlays
zipstream
n2
lgpl
subdirectories
nscharacterset
simultaneous
table-valued-parameters
chromebug
web-widget
managed-code

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App