Open stillesjo opened 9 years ago
Just saw the PR that handles strict mode. How about single-quote though?
This is a workaround I use
gulp.task('config', function () {
gulp.src('app/config.json')
.pipe(ngConstant({
// ngConstant options
}))
// add 'use strict;', and change double quotes to single quotes
// or you can add jshint ignore instead
.pipe( through2.obj((chunk, enc, callback) => {
var str = chunk.contents.toString();
str = str.replace(/"/g, '\'')
.replace('angular.module', `'use strict';\r\nangular.module`);
// replace contents
chunk.contents = new Buffer(str);
// done
callback(null, chunk);
}) )
// optional: use jsbeautifier to prettify js
.pipe( plugins.jsbeautifier({
indentSize: 2,
preserveNewlines: false
}) )
.pipe(gulp.dest('dist'));
});
A bit shorter code:
gulp.task('config', function () {
gulp.src('app/config.json')
.pipe(ngConstant({
// ngConstant options
}))
// add 'use strict;', (commented because I don't need that part)
// .pipe(replace('angular.module', `'use strict';\r\nangular.module`));
// change double quotes to single quotes
// or you can add jshint ignore instead
.pipe(replace(/"/g, '\''))
.pipe(gulp.dest('dist'));
});
You will also need var replace = require('gulp-replace');
at the top of your file and "gulp-replace": "~0.5.3",
in your package.json.
Also, don't forget to run npm install
after editing package.json.
@loren138 : Ah yes...using gulp-replace is better idea!
While dependency injecting a generated constant module, I get the following lint errors/warnings
I'm aware that I can create own template files to avoid these lint entries but I think it would be a good idea if this could work directly.