I have the following gulp file:
var gulp = require('gulp'),
browserify = require('browserify'),
babelify = require('babelify'),
source = require('vinyl-source-stream'),
gutil = require('gulp-util');
cssnano = require('gulp-cssnano'),
autoprefixer = require('gulp-autoprefixer'),
sass = require('gulp-ruby-sass'),
notify = require('gulp-notify'),
eslint = require('gulp-eslint'),
sourcemaps = require('gulp-sourcemaps');
gulp.task('sass', function () {
return sass('scss/style.scss', { sourcemap: true })
.on('error', sass.logError)
.pipe(autoprefixer({
browsers: ["last 4 versions", "Firefox >= 27", "Blackberry >= 7", "IE 8", "IE 9"],
cascade: false
}))
.pipe(cssnano())
// For inline sourcemaps
.pipe(sourcemaps.write())
// For file sourcemaps
.pipe(sourcemaps.write('maps', {
includeContent: false,
sourceRoot: 'scss'
}))
.on('error', function(e) {
console.log(e);
})
.pipe(gulp.dest("css"))
.pipe(notify("SASS compilation complete: <%=file.relative%>"))
});
gulp.task('lint', () => {
// ESLint ignores files with "node_modules" paths.
// So, it's best to have gulp ignore the directory as well.
// Also, Be sure to return the stream from the task;
// Otherwise, the task may end before the stream has finished.
return gulp.src(['./js/components/*.js'])
// eslint() attaches the lint output to the "eslint" property
// of the file object so it can be used by other modules.
.pipe(eslint({configFile: 'eslint.json'}))
// eslint.format() outputs the lint results to the console.
// Alternatively use eslint.formatEach() (see Docs).
.pipe(eslint.format())
// To have the process exit with an error code (1) on
// lint error, return the stream and pipe to failAfterError last.
.pipe(eslint.failAfterError());
});
gulp.task('es6', function() {
browserify({
entries: './ES6/script.js',
debug: true,
transform: [babelify.configure({
presets: ['es2015']
})]
})
.transform(babelify)
.on('error',gutil.log)
.bundle()
.on('error',gutil.log)
.pipe(source('script.js'))
.pipe(gulp.dest('js'));
});
gulp.task('watch',function() {
gulp.watch('./ES6/script.js',{debounceDelay: 5000},['lint', 'es6'])
gulp.watch("scss/style.scss", ['sass'])
});
gulp.task('default', ['lint', 'es6', 'sass', 'watch']);
and a package.json like so:
{
"name": "",
"version": "1.0.0",
"description": " ",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": ""
},
"author": "",
"license": "ISC",
"homepage": "",
"devDependencies": {
"babel-preset-es2015": "^6.24.0",
"babelify": "^7.3.0",
"browserify": "^14.1.0",
"gulp": "^3.9.1",
"gulp-autoprefixer": "^3.1.1",
"gulp-cssnano": "^2.1.2",
"gulp-eslint": "^3.0.1",
"gulp-notify": "^3.0.0",
"gulp-ruby-sass": "^2.1.1",
"gulp-sourcemaps": "^2.4.1",
"gulp-util": "^3.0.8",
"reflex-grid": "^1.5.0",
"vinyl-source-stream": "^1.1.0"
},
"dependencies": {
"core-js": "^2.4.1",
"normalize.css": "^7.0.0"
}
}
it works all fine on my machine, however when somebody runs "npm install" and then run "gulp" they get the following error:
gulpfile.js:42 gulp.task(‘lint’, () => {
^
SyntaxError: Unexpected token )
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
via Alex
No comments:
Post a Comment