コード例 #1
0
ファイル: index.js プロジェクト: akoutmos/gulp-pug-lint
    rc.for(file.path, function(errRc, conf) {
      if (errRc) {
        return cb(new gutil.PluginError('gulp-pug-lint', errRc));
      }

      try {
        var linter = new PugLint();
        linter.configure(configParser(conf));

        var errors = linter.checkFile(file.path);

        if (errors.length) {
          throw new gutil.PluginError('gulp-pug-lint', errors[0].message);
        }
      } catch (errLint) {
        return cb(new gutil.PluginError('gulp-pug-lint', errLint));
      }

      cb(null, file);
    });
コード例 #2
0
ファイル: puglint.js プロジェクト: Antiavanti/grunt-puglint
  grunt.registerMultiTask('puglint', 'Grunt plugin for pug-lint', function () {
    var done = this.async();
    var options = this.options({
      preset: 'clock'
    });

    if (typeof options.preset === 'object') {
      options = options.preset;
    }

    var pugLintRc = options.puglintrc;
    if (pugLintRc) {
      if (grunt.file.exists(pugLintRc)) {
        options = grunt.file.readJSON(pugLintRc);
      } else {
        grunt.log.error('Configuration file not found. Used a standard config: `clock`.');
      }
    }

    linter.configure(options);

    if (this.filesSrc.length === 0) {
      done();
      return;
    }

    var errors = [];
    var failed = false;
    this.filesSrc.forEach(function(filepath) {
      errors = linter.checkFile(filepath);

      if (errors.length) {
        failed = true;
        formatter.formatOutput(errors);
      }
    });

    done(!failed);
  });