1.1.0 • Published 6 years ago

gulp-checker v1.1.0

Weekly downloads
33
License
MIT
Repository
github
Last release
6 years ago

npm npm Dependency Status devDependency Status peerDependency Status

gulp-checker

$ npm install gulp-checker --save-dev
/*eslint-env node*/

const fs = require('fs');
const path = require('path');
const gulp = require('gulp');
const check = require('gulp-checker');



module.exports = () =>
  gulp
    .src([ 'filters/*.js' ])
    .pipe(check({
      name: 'Check filters',
      map: (file) => {
        const dir = path.dirname(file.path);
        const name = path.basename(file.path).replace(/\.js$/, '');

        return {
          name,
          hasTestFile: fs.existsSync(path.join(dir, '__tests__', `${name}.test.js`))
        };
      },
      checkers: [
        ({ name }, { CheckError }) => {
          if (!/^[a-z0-9]+[a-z0-9-]+?[a-z0-9]+$/.test(name)) {
            return CheckError('invalid name format');
          }

          return null;
        },
        ({ hasTestFile }, { CheckError }) => {
          if (!hasTestFile) {
            return CheckError('no test file');
          }

          return null;
        }
      ]
    }));
1.1.0

6 years ago

1.0.1

7 years ago

1.0.0

7 years ago