mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-11-26 02:30:21 -06:00
4d8b7556f8
Also, changed the 'linter' yarn-command to use this script. This script will run the 'eslint' against all the static javascripts, found under pgadmin and regression directories of source (excepts 'vendor', 'generated'). It also allows to run the 'eslint' against specific javascript file[s]. In order to run eslint on all static javascript files, run the following command: yarn run linter node pga_eslint In order to run eslint on specific files, run the following command: yarn run linter --file <filename> [<filename>] node pga_script --file <filename> [<filename>] In order to provide eslint specific commands, run the following command: yarn run linter [--file <filename> [<filename>]] --eslint-options node pga_script [--file <filename> [<filename>]] --eslint-options i.e. yarn run linter --fix yarn run linter --debug node pga_eslint --fix --debug pgadmin/static/js/pgadmin.js
44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
/* eslint no-console:off */
|
|
'use strict';
|
|
|
|
const debug = (process.argv.indexOf('--debug') > -1),
|
|
file_argv = process.argv.indexOf('--file');
|
|
var argv = process.argv;
|
|
|
|
if (file_argv > -1) {
|
|
argv.splice(file_argv, 1);
|
|
} else {
|
|
argv = argv.concat(['--ignore-pattern', __filename]);
|
|
}
|
|
|
|
// must do this initialization *before* other requires in order to work
|
|
if (debug) {
|
|
require('debug').enable('eslint:*,-eslint:code-path');
|
|
}
|
|
|
|
const fs = require('fs'),
|
|
path = require('path'),
|
|
read = (dir) =>
|
|
fs.readdirSync(dir)
|
|
.reduce((files, file) =>
|
|
fs.statSync(path.join(dir, file)).isDirectory() ?
|
|
files.concat(read(path.join(dir, file))) :
|
|
((file, files) => (
|
|
file.indexOf(path.sep + 'generated' + path.sep) === -1 &&
|
|
file.indexOf(path.sep + 'vendor' + path.sep) === -1 &&
|
|
file.indexOf(path.sep + 'static' + path.sep) > -1 &&
|
|
(file.endsWith('.js') || file.endsWith('.jsx')) &&
|
|
files.concat(file) || files
|
|
))(path.join(dir, file), files), []),
|
|
eslint_cli = require('eslint/lib/cli');
|
|
|
|
process.exitCode = eslint_cli.execute(
|
|
file_argv > -1 ? argv : argv.concat(
|
|
read(path.join(__dirname, 'pgadmin'))
|
|
).concat(
|
|
'regression/javascript/**/*.jsx regression/javascript/**/*.js *.js'
|
|
)
|
|
);
|