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 not installed globally?
gulp-useref deep folders error
use gulp+browserify+reactify, can't emit exit when got a ReactifyError
gulp-browserstack and gulp-cucumber don't seem to play nicely together
Gulp - Babel - EcmaScript-6 - Redux / Unhandled stream error in pipe
Delete all files using gulp except once that match pattern
Gulp task 'inject:vendor' does not inject Bower dependencies
Why do you open a gulp src pipe when you use gulp-watch?
Atom action performed on save
Gulp BrowserSync not working with SCSS
run gulp-clean-css options in gulp-inline
Is it possible to run gulp tasks after linting?
How to male a snapshot/dump from gulp installation and settings?
My browsersync server refreshes the page but with old content
Iterate a JSON object in Jade using gulp-data?
Failed to load resource 404 (Not Found)

Categories

HOME
asp.net
logging
autohotkey
ckan
cluster-analysis
ldap
android-ndk
bigtable
reference
nagios
sdk
msbi
uml-designer
clip-path
segmentation-fault
google-app-maker
core-data
mamp
guidewire
fine-uploader
saucelabs
github-flavored-markdown
multibinding
samba
orange
autologin
scotty
datasource
android-wifi
gomobile
datazen-server
javaagents
inline-assembly
quality-center
chartist.js
libxml2
drawrect
imdb
visual-prolog
luhn
tunnel
stochastic-process
idea-plugin
binary-decision-diagram
qt-quick
peerjs
superclass
bootstrap-carousel
spring-webflow-2
jcs
photoshop-script
sharpssh
programming-pearls
dynatable
addressbook
blackberry-webworks
jigsaw
django-taggit
audiorecord
database-administration
window.location
paypal-subscriptions
jcalendar
ooad
ios8-share-extension
serial-communication
php-gd
persian
personality-insights
syncano
hexagonal-tiles
joomla3.3
page-refresh
cakephp-2.6
valdr-bean-validation
connection-timeout
service-broker
optimistic-locking
uiblureffect
disparity-mapping
ccmenuitem
msdropdown
episerver-7
banana-pi
smartxls
email-headers
fastcgi-mono-server
android-jack-and-jill
nvcc
nomachine
imaplib
misfire-instruction
nsnumber
infinity.js
removeall
pymel
django-admin-tools
automapper-2
httppostedfilebase
lwp
linq-to-mysql
pkcs#7

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