Example #1
0
 gulp.task(options.taskName, function() {
   return gulp.src(src)
     .pipe(cache(options.taskName))
     .pipe(jshint())
     .pipe(jshint.reporter(jshintStylish))
     .pipe(gulpif(options.shouldFail, jshint.reporter('fail')))
     .pipe(jscs())
     .pipe(jscs.reporter(jscsStylish))
     .pipe(gulpif(options.shouldFail, jscs.reporter('fail')))
     .pipe(complexity({
       cyclomatic: [5, 15, 25],
       halstead: [15, 20, 25],
       maintainability: 100,
       breakOnErrors: false
     }));
 });
gulp.task('script', function() {
  gulp.src('src/scripts/main.js')
  .pipe(sourcemaps.init())
  .pipe(jshint())
  .pipe(jshint.reporter('jshint-stylish'))
  .pipe(jscs('.jscsrc'))
  .on('error', errorNotify)
  .pipe(gulp.dest(destinations.js))
  .pipe(uglify())
  .on('error', errorNotify)
  .pipe(rename({suffix: '.min'}))
  .pipe(sourcemaps.write('/'))
  .on('error', errorNotify)
  .pipe(gulp.dest(destinations.js))
  .pipe(notify({ message: 'Script task complete' }));
});
Example #3
0
gulp.task('jscs', function() {
    gulp.src(['src/**/*.js'])
        .pipe(jscs({
            fix: true
        }))
        .pipe(jscs.reporter())
        .pipe(gulp.dest('src'))
        .on('finish', function() {
            gulp.src(['test_src/**/*.js'])
                .pipe(jscs({
                    fix: true
                }))
                .pipe(jscs.reporter())
                .pipe(gulp.dest('test_src'));
        });
});
Example #4
0
gulp.task('lint:html', function() {
  return gulp.src([
        '*.html',
        'demo/*.html',
        'test/*.html'
      ])
      .pipe(htmlExtract({
        sel: 'script, code-example code'
      }))
      .pipe(jshint())
      .pipe(jshint.reporter())
      .pipe(jshint.reporter('fail'))
      .pipe(jscs())
      .pipe(jscs.reporter())
      .pipe(jscs.reporter('fail'));
});
gulp.task('scripts', ['clean'], function() {
 gulp.src(paths.scripts, {cwd: bases.app})
 .pipe(jshint())
 .pipe(jshint.reporter('default'))
 .pipe(jscs())
 .pipe(jscs.reporter())
 .pipe(uglify())
 .pipe(concat('gridstack-angular.min.js'))
 .pipe(header(banner, { pkg : pkg } ))
 .pipe(gulp.dest(bases.dist));

 gulp.src(paths.scripts, {cwd: bases.app})
 .pipe(concat('gridstack-angular.js'))
 .pipe(header(banner, { pkg : pkg } ))
 .pipe(gulp.dest(bases.dist));
});
Example #6
0
gulp.task('jscs', function() {
    gulp.src(info.src.js + '/**/*.js')
        .pipe(jscs())
        .pipe(notify({
            title: 'JSCS',
            message: 'JSCS Passed. Let it fly!'
        }))

        /* Alternatively for Windows users
        .pipe(notify({
            title: 'JSCS',
            message: 'JSCS Passed. Let it fly!',
            notifier: growlNotifier
        }))
        */
});
Example #7
0
gulp.task('lint-code', function () {
  return gulp
    .src([
      './gulpfile.js',
      './index.js',
      './bin/**/*',
      './lib/**/*.js',
      '!./lib/assets/**/*.js',
      './test/**/*.js',
      '!./test/support/tmp/**/*.js'
    ])
    .pipe(jscs())
    .pipe(jshint())
    .pipe(jshint.reporter('default'))
    .pipe(jshint.reporter('fail'));
});
Example #8
0
gulp.task('scripts-app', ['docs-js'], function() {
  var jshint = require('gulp-jshint'),
      jscs = require('gulp-jscs'),
      map = require('map-stream'),
      ngannotate = require('gulp-ng-annotate'),
      stripDebug = require('gulp-strip-debug'),
      stylish = require('jshint-stylish'),
      sourcemaps = require('gulp-sourcemaps'),
      uglify = require('gulp-uglify'),
      exitOnJshintError = map(function (file, cb) {
        if (!file.jshint.success) {
          gutil.error('jshint failed');
          process.exit(1);
        }
        cb();
      });

  return gulp.src(settings.src + 'js/app/**/*.js')
    .pipe(plumber())
    .pipe(jscs({
      preset: "node-style-guide", 
      verbose: true,
      // disable or change rules
      "requireTrailingComma": null,
      "validateLineBreaks": "CRLF",
      "disallowTrailingWhitespace": null,
      "maximumLineLength": 120,
      "disallowMultipleVarDecl": null
    }))

    .pipe(jshint('.jshintrc'))
    .pipe(jshint.reporter(stylish))
    // .pipe(exitOnJshintError)

    .pipe(ngannotate({gulpWarnings: false}))
    .pipe(concat('app.js'))
    .pipe(gulp.dest(settings.dist + 'js'))
    
    // make minified 
    .pipe(rename({suffix: '.min'}))
    .pipe(gulpif(!argv.dev, stripDebug()))
    .pipe(sourcemaps.init())
    .pipe(gulpif(!argv.dev, uglify()))
    .pipe(sourcemaps.write())
    .pipe(size({"showFiles":true}))
    .pipe(gulp.dest(settings.dist + 'js'));
});
Example #9
0
function codeStyleTaskHandler(callback) {
  var paths = [
    'gulpfile.js',
    'app.js',
    './routes/**/*.js',
    './middlewares/**/*.js',
    './models/**/*.js',
    './modules/**/*.js',
    './config/**/*.js'
  ];
  var srcOpts = { read: true };
  
  gulp
    .src(paths, srcOpts)
    .pipe(jscs());
  callback(null);
}
Example #10
0
gulp.task('lint-js', function () {
    return merge([                              // Combine multiple streams to one and return it so the task can be chained.
        gulp.src(lintSources.js)                // Start with the source .js files.
            .pipe(plumber())                    // Handle any errors.
            .pipe(jshint())                     // Get any JavaScript linting errors.
            .pipe(jshint.reporter('default', {  // Report any JavaScript linting errors to the console.
                verbose: true
            })),
        gulp.src(lintSources.ts)                // Start with the source .ts files.
            .pipe(plumber())                    // Handle any errors.
            .pipe(tslint())                     // Get any TypeScript linting errors.
            .pipe(tslint.report('verbose')),    // Report any TypeScript linting errors to the console.
        gulp.src(lintSources.js)                // Start with the source .js files.
            .pipe(plumber())                    // Handle any errors.
            .pipe(jscs())                       // Get and report any JavaScript style linting errors to the console.
    ]);
});
gulp.task("lint-js", function () {
    return merge([                                                  // Combine multiple streams to one and return it so the task can be chained.
        gulp.src(paths.scripts + "**/*.js")                         // Start with the source .js files.
            .pipe(plumber())                                        // Handle any errors.
            .pipe(jshint())                                         // Get any JavaScript linting errors.
            .pipe(jshint.reporter("default", {                      // Report any JavaScript linting errors to the console.
                verbose: true
            })),
        gulp.src(paths.scripts + "**/*.ts")                         // Start with the source .ts files.
            .pipe(plumber())                                        // Handle any errors.
            .pipe(tslint())                                         // Get any TypeScript linting errors.
            .pipe(tslint.report("verbose")),                        // Report any TypeScript linting errors to the console.
        gulp.src(paths.scripts + "**/*.js")                         // Start with the source .js files.
            .pipe(plumber())                                        // Handle any errors.
            .pipe(jscs())                                           // Get and report any JavaScript style linting errors to the console.
    ]);
});
Example #12
0
gulp.task('lint', function() {
   return gulp.src([
      path.join(__dirname, '/*.js'),
      path.join(__dirname, '/test/*.js')
   ],
   {
      base: './'
   })
   .pipe(jshint())
   .pipe(jscs({
      fix: true
   }))
   .pipe(stylish.combineWithHintResults())
   .pipe(jscs.reporter())
   .pipe(jshint.reporter('jshint-stylish'))
   .pipe(gulp.dest('.'));
});
Example #13
0
    gulp.task('dist_js_lint', function() {

        return gulp
            .src(tasks.dist_js.source)
            .pipe(jscs())
            .pipe(jshint())
            .pipe(jshint.reporter('default'))
            .pipe(gulp.dest(tasks.dist_js.dest))
            .pipe(notify({
                title: 'Javascript',
                message: '<%= file.relative %> linted successfully',
                onLast: true
            }))
            .on('error', notify.onError(function (error) {
                return 'Message to the notifier: '+ error.message;
            }));

    });
Example #14
0
gulp.task('static', function () {
  return gulp.src([
    'test/*.js',
    'lib/**/*.js',
    'benchmark/**/*.js',
    'index.js',
    'doc.js',
    'gulpfile.js'
  ])
  .pipe(jshint('.jshintrc'))
  .pipe(jshint.reporter('jshint-stylish'))
  .pipe(jshint.reporter('fail'))
  .pipe(jscs())
  .on('error', handleErr);
  // .pipe(eslint())
  // .pipe(eslint.format())
  // .pipe(eslint.failOnError());
});
Example #15
0
gulp.task("jscs", function() {
  return gulp.
  src(paths.allFiles).
  pipe(jscs({
    "preset": "google",
    "requireParenthesesAroundIIFE": true,
    "maximumLineLength": 120,
    "validateLineBreaks": "LF",
    "validateIndentation": 2,
    "validateQuoteMarks": "\"",

    "disallowKeywords": ["with"],
    "disallowSpacesInsideObjectBrackets": null,
    "disallowImplicitTypeConversion": ["string"],
    "requireCurlyBraces": [],

    "safeContextKeyword": "self"
  }));
});
gulp.task('static', false, function() {

    var status = {
        hasShown: false,
        hasError: false,
        errs: []
    };
    return gulp.src(constants.lint)
        .pipe(plumber({
            errorHandler: function(err) {
                if (err.plugin === 'gulp-jscs') {
                    gutil.log(err.toString());
                }
                status.hasError = true;
                status.errs.push(err);
                if (!status.hasShown) {
                    status.hasShown = true;

                    this.emit('end');
                }
            }
        }))
        .pipe(jshint({
            lookup: true
        }))
        .pipe(jshint.reporter('jshint-stylish'))
        .pipe(jscs())
        .pipe(eslint())
        .pipe(eslint.format())
        .pipe(jshint.reporter('fail'))
        .pipe(eslint.failOnError())
        .on('end', function() {
            if (status.hasError) {
                gutil.log(chalk.red('lint failed'));
                throw new Error('lint_error');

            } else {
                gutil.log(chalk.green('All lint files passed'));

            }
        });

});
Example #17
0
 compileJs: function(config) {
   // JS compile function
   // Additional options, such as wether to lint, check code style or minify,
   // are supplied with the gulp.config.json file.
   return gulp.src(config.assetsSrc + '/js/**/*.js')
     .pipe(gulpif(config.verbose, gulpPrint(function(filepath) {
       return 'running js-task on: ' + filepath;
     })))
     .pipe(gulpif(config.jscs, jscs()))
     .pipe(gulpif(config.jscs, jscs.reporter()))
     .pipe(gulpif(config.jshint, jshint()))
     .pipe(gulpif(config.jshint, jshint.reporter('jshint-stylish', { verbose: true })))
     .pipe(gulpif(config.jshint, jshint.reporter('fail')))
     .pipe(concat('scripts.js'))
     .pipe(gulpif(config.sourceMaps, sourcemaps.init({ loadMaps: true })))
       .pipe(gulpif(config.minify, uglify()))
       .on('error', util.log)
     .pipe(gulpif(config.sourceMaps, sourcemaps.write('./')))
     .pipe(gulp.dest(config.defaultDest + '/scripts'));
 }
Example #18
0
gulp.task('lint', ['ensureFiles'], function() {
    return gulp.src([
            'app/scripts/**/*.js',
            'app/elements/**/*.js',
            'app/elements/**/*.html',
            'gulpfile.js'
        ])
        .pipe(reload({
            stream: true,
            once: true
        }))

    // JSCS has not yet a extract option
    .pipe(gulpIf('*.html', htmlExtract()))
        .pipe(jshint())
        .pipe(jscs())
        .pipe(jscsStylish.combineWithHintResults())
        .pipe(jshint.reporter('jshint-stylish'))
        .pipe(gulpIf(!browserSync.active, jshint.reporter('fail')));
});
Example #19
0
gulp.task('scripts', function () {

  return gulp.src('./source/scripts/**/*.js')
    .pipe(changed('./build/scripts'))

  // Include JS
  // Similar to Sass `@import`
    .pipe(include())

  // Check JSCS
    .pipe(jscs({
      configPath: './gulp_tasks/conf/js-guide.json',
    }))

  // Lint JS
    .pipe(jshint(jshintConf))
    .pipe(pkg.stage < 2 ? jshint.reporter(stylish) : babel({
      presets: ['es2015'],
    }))

  // Add banner
  //.pipe(header(banner, {
  //  pkg: pkg,
  //  moment: moment
  //}))

  // Save uncompressed JS
    .pipe(gulp.dest('./build/scripts'))

  // Minify JS
  //.pipe(uglify({
  //  preserveComments: 'some'
  //}))
  // Add `.min` suffix
  //.pipe(rename({
  //  suffix: '.min'
  //}))

  // Save compressed JS
    .pipe(gulp.dest('./build/scripts'));
});
 // JS compile function
 // This is the main javascript compilation function.
 // src: the path to the javascript file(s). Optionally a glob pattern
 // filename: the name of the concatenated, optionally minified output file
 // dest: the destination path of the output file
 // Additional options, such as wether to lint, check code style or minify,
 // are supplied with the gulp.config.json file.
 function compileJs(src, filename, dest) {
   return gulp.src(src)
     .pipe(gulpif(config.verbose, gulpPrint(function(filepath) {
       return 'running js-task on: ' + filepath;
     })))
     .pipe(gulpif(config.jscs, jscs()))
     .pipe(gulpif(config.jscs, jscs.reporter()))
     .pipe(gulpif(config.jshint, jshint()))
     .pipe(gulpif(
       config.jshint,
       jshint.reporter('jshint-stylish', { verbose: true }))
     )
     .pipe(gulpif(config.jshint, jshint.reporter('fail')))
     .pipe(concat(filename))
     .pipe(gulpif(config.sourceMaps, sourcemaps.init({ loadMaps: true })))
       .pipe(ngAnnotate())
       .pipe(gulpif(config.minify, uglify()))
       .on('error', util.log)
     .pipe(gulpif(config.sourceMaps, sourcemaps.write('./')))
     .pipe(gulp.dest(dest + '/scripts'));
 }
Example #21
0
var TestValidJavascript = function() {
    var deferred = Q.defer();

    process.stdout.write(chalk.blue('(3/11)') + ' Testing all JavaScript code is valid: ');

    gulp.src('./src/**/*.js')
        .pipe(jscs())
        .pipe(jshint())
        .pipe(jshint.reporter('jshint-stylish'))
        .pipe(jshint.reporter('fail'))

    .on('finish', function() {
        deferred.resolve(true);
        console.log(chalk.green('Complete'));
    }, function() {
        deferred.reject(true);
        console.log(chalk.red('Failed'));
    });

    return deferred.promise;
};
gulp.task('scripts', () => {
  // run from base to include files in site root and elements folder
  return gulp.src(sourceFiles)
    .pipe(debug({
      title: 'scripts:'
    }))
    .pipe(jshint())
    .pipe(jshint.reporter('jshint-stylish'))
    // .pipe(gulpif(!browserSync.active, jshint.reporter('fail')))
    .pipe(sourcemaps.init())
    .pipe(jscs({
      fix: true
    }))
    .pipe(babel())
    // .pipe(concat('app-min.js'))
    // .pipe(modernizr())
    .pipe(uglify())
    .pipe(sourcemaps.write('./maps'))
    .pipe(gulp.dest(config.path.destination.base))
    .on('error', reportError);
});
Example #23
0
    gulp.task('dist:scripts', function() {

        gulp.src(config.paths.app.scripts, {'base': 'src'})
            .pipe(jscs({
                configPath: config.jscsrc
            }).on('error', function(err) {
                console.log('JSCS error detected... aborting build process\n' + err.message);
                process.exit(1); // exit with error code
            }))
            .pipe(jshint())
            .pipe(jshint.reporter('default'))
            .pipe(jshint.reporter('fail')); // fail build if jshint finds problems

        //now we add the libs and partials for the minification
        return gulp.src(config.paths.lib.scripts.prod.concat(
            config.paths.app.scripts).concat(join(config.distDir, '/partials.js')), {'base': 'src'})
            .pipe(concat('all.js'))
            .pipe(ngAnnotate())
            .pipe(uglify('fail'))
            .pipe(gulp.dest(config.distDir));
    });
Example #24
0
gulp.task('scripts', function() {

  return gulp.src('./source/scripts/*.js')

    // Include JS
    // Similar to Sass `@import`
    .pipe(include())

    // Check JSCS
    .pipe(jscs({
      configPath: './gulp_tasks/_js-guide.json'
    }))

    // Lint JS
    .pipe(jshint(jshintConfig))
    .pipe(jshint.reporter(stylish))

    // Add banner
    .pipe(header(banner, {
      pkg: pkg,
      moment: moment
    }))

    // Save uncompressed JS
    .pipe(gulp.dest('./build/scripts'))

    // Minify JS
    .pipe(uglify({
      preserveComments: 'some'
    }))

    // Add `.min` suffix
    .pipe(rename({
      suffix: '.min'
    }))

    // Save compressed JS
    .pipe(gulp.dest('./build/scripts'));
});
/**
 * Task: `reduxCombineModules`.
 *
 * Concatenate redux.js modules into master redux.js file.
 * reduxJS task is dependant upon this task to properly compete.
 *
 * This task does the following:
 *     1. Gets the source folder for Redux JS javascrip modules.
 *     2. Concatenates all the files and generates redux.js
 */
function reduxCombineModules( done ){
	'use strict';

	gulp.src( jsReduxSRC )
	.pipe( jshint() )
	.pipe( jshint.reporter( 'default' ) )
	.pipe( jscs() )
	.pipe( jscs.reporter() )
	.pipe(
		rename(
			{
				basename: jsReduxFile,
				suffix: '.min'
			}
		)
	)
	.pipe( uglify() )
	.pipe( lineec() )
	.pipe( gulp.dest( jsReduxDestination ) );

	done();
}
Example #26
0
gulp.task('js', function() {
  return gulp.src('src/**/*.js')
    .pipe(plumber(plumberHandler))
    .pipe(replace(
      'REPLACE-DEFAULT-TEMPLATE',
      fs.readFileSync('src/tik-tok.tpl.html', {
        encoding: 'utf-8'
      }).replace(/'/g, '\\\'').replace(/(\r\n|\n|\r|\s+)/g, ' ')
    ))
    .pipe(jshint())
    .pipe(jshint.reporter('jshint-stylish'))
    .pipe(jshint.reporter('fail'))
    .pipe(jscs())
    .pipe(header(banner, { pkg: pkg }))
    .pipe(gulp.dest('dist'))
    .pipe(uglify())
    .pipe(header(banner, { pkg: pkg }))
    .pipe(rename({
      extname: '.min.js'
    }))
    .pipe(gulp.dest('dist'));
});
Example #27
0
gulp.task('build', function () {
    return gulp.src(files)
        .pipe(jscs())
        .pipe(jshint())
        .pipe(jshint.reporter('default'))
        .pipe(concat('domtokenlist.js'))
        .pipe(header('/*! DOMTokenlist shim | Copyright <%= new Date().getFullYear() %> Jonathan Wilsson and Bogdan Chadkin. */\n'))
        .pipe(size({
            showFiles: true
        }))
        .pipe(gulp.dest('dist'))
        .pipe(uglify({
            preserveComments: 'some'
        }))
        .pipe(rename({
            suffix: '.min'
        }))
        .pipe(size({
            showFiles: true
        }))
        .pipe(gulp.dest('dist'));
});
		gulp.task("check-js-style", "Enforce JavaScript code style", () =>{
			return gulp.plumbedSrc(// handle errors nicely (i.e., without breaking watch)
				config.javascript.src
			)

				// Display the files in the stream
				//.pipe(debug({title: "Stream contents:", minimal: true}))

				// Check JS code style (uses .jscsrc)
				.pipe(
				jscs({
					esnext: true, // seems broken: https://github.com/jscs-dev/gulp-jscs/issues/69
					fix: false
				})
			)

				.pipe(jscsStylish()) // log style errors

				// Task result
				.pipe(size({
					title: "check-js-style"
				}));
		});
function reduxSpinner( done ) {
	'use strict';

	gulp.src( './ReduxCore/inc/fields/spinner/vendor/jquery.ui.spinner.js' )
	.pipe( jshint() )
	.pipe( jshint.reporter( 'default' ) )
	.pipe( jscs() )
	.pipe( jscs.reporter() )

	.pipe(
		rename(
			{
				basename: 'jquery.ui.spinner',
				suffix: '.min'
			}
		)
	)
	.pipe( uglify() )
	.pipe( lineec() )
	.pipe( gulp.dest( './ReduxCore/inc/fields/spinner/vendor/' ) );

	done();
}
function reduxMedia( done ) {
	'use strict';

	gulp.src( './ReduxCore/assets/js/media/media.js' )
	.pipe( jshint() )
	.pipe( jshint.reporter( 'default' ) )
	.pipe( jscs() )
	.pipe( jscs.reporter() )

	.pipe(
		rename(
			{
				basename: 'media',
				suffix: '.min'
			}
		)
	)
	.pipe( uglify() )
	.pipe( lineec() )
	.pipe( gulp.dest( './ReduxCore/assets/js/media/' ) );

	done();
}