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 watch for css doesn't work
Using gulp for compiling of changed files only
How to run gulp task in visual studio code?
BrowserSync with custom URL
Multi-tenancy and Semantic UI
Display total number of errors with Gulp Jshint
Gulp watch entire folder & compile saved file
elixir.queueTask is undefined
gulp : browserify then concat files
parse error on vinyl source stream on gulp browserify babelify project
Bitters error (“Undefined variable: $font-stack-system”)
Gulp Babel Issue Using Foundation
Can gulp-rev inside individual tasks merge into one manifest?
Angular2 “Getting Started” deployment with SystemJS
Error: Requiring external module babel-register
Add Browserify as the last step in gulp task's transformations

Categories

HOME
qlikview
internet-explorer
oop
msbuild
stanford-nlp
oracle-sqldeveloper
popover
gap-system
blob
perl6
handlebars.js
google-app-maker
theory
select2
drush
opendaylight
console-application
dat.gui
samba
virtuemart
formulas
vala
procedural-generation
struts
inspec
ballerinalang
stack-trace
multiple-inheritance
angular2-changedetection
marionette
large-files
sqldependency
pushpad
selenium3
lines
tikz
ng2-bootstrap
zimbra
matlab-compiler
flex3
campaign-monitor
sdl-2
maven-2
motion
origami
lfe
rbac
tapply
compiler-warnings
php-mongodb
firefox-developer-edition
nshttpurlresponse
logan-square
easyquery
django-tables2
google-cloud-shell
openidm
jscoverage
aws-rds
boost-regex
programming-pearls
esprima
spring-social-twitter
symantec
konakart
cosign-api
cherry-pick
supervised-learning
python-rq
chomsky-normal-form
alchemy
music-player
apache2-module
gtkwave
bioconductor
php-gd
page-refresh
applinks
gnip
disabled-control
isl
debuggervisualizer
banana-pi
rda
yandex-api
pidgin
kernel-density
nop
ekevent
code-complete
google-mirror-api
mencoder
backbone-views
qmainwindow
freeimage
jquery-1.8
event-propagation
sup
optimistic-concurrency
zend-validate
xpolog
auto-compile
xcdatamodel
glassfish-embedded
uccapi
jgrowl
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