mirror of https://github.com/zulip/zulip.git
719546641f
Babel polyfills this for us for Internet Explorer. import * as babelParser from "recast/parsers/babel"; import * as recast from "recast"; import * as tsParser from "recast/parsers/typescript"; import { builders as b, namedTypes as n } from "ast-types"; import K from "ast-types/gen/kinds"; import fs from "fs"; import path from "path"; import process from "process"; const checkExpression = (node: n.Node): node is K.ExpressionKind => n.Expression.check(node); for (const file of process.argv.slice(2)) { console.log("Parsing", file); const ast = recast.parse(fs.readFileSync(file, { encoding: "utf8" }), { parser: path.extname(file) === ".ts" ? tsParser : babelParser, }); let changed = false; recast.visit(ast, { visitBinaryExpression(path) { const { operator, left, right } = path.node; if ( n.CallExpression.check(left) && n.MemberExpression.check(left.callee) && !left.callee.computed && n.Identifier.check(left.callee.property) && left.callee.property.name === "indexOf" && left.arguments.length === 1 && checkExpression(left.arguments[0]) && ((["===", "!==", "==", "!=", ">", "<="].includes(operator) && n.UnaryExpression.check(right) && right.operator == "-" && n.Literal.check(right.argument) && right.argument.value === 1) || ([">=", "<"].includes(operator) && n.Literal.check(right) && right.value === 0)) ) { const test = b.callExpression( b.memberExpression(left.callee.object, b.identifier("includes")), [left.arguments[0]] ); path.replace( ["!==", "!=", ">", ">="].includes(operator) ? test : b.unaryExpression("!", test) ); changed = true; } this.traverse(path); }, }); if (changed) { console.log("Writing", file); fs.writeFileSync(file, recast.print(ast).code, { encoding: "utf8" }); } } Signed-off-by: Anders Kaseorg <anders@zulipchat.com> |
||
---|---|---|
.. | ||
ci | ||
circleci | ||
documentation_crawler | ||
droplets | ||
i18n | ||
lib | ||
linter_lib | ||
setup | ||
test-install | ||
tests | ||
zulip-export | ||
README.md | ||
__init__.py | ||
build-docs | ||
build-release-tarball | ||
cache-zulip-git-version | ||
check-capitalization | ||
check-frontend-i18n | ||
check-issue-labels | ||
check-openapi | ||
check-provision | ||
check-templates | ||
clean-branches | ||
clean-repo | ||
commit-message-lint | ||
commit-msg | ||
conf.ini-template | ||
coveragerc | ||
create-test-api-docs | ||
deploy-branch | ||
diagnose | ||
django-template-graph | ||
do-destroy-rebuild-database | ||
do-destroy-rebuild-test-database | ||
documentation.vnufilter | ||
fetch-pull-request | ||
fetch-rebase-pull-request | ||
find-unused-css | ||
get-handlebar-vars | ||
html-grep | ||
js-dep-visualizer.py | ||
lint | ||
pre-commit | ||
pretty-print-html | ||
provision | ||
push-to-pull-request | ||
release-tarball-exclude.txt | ||
renumber-migrations | ||
replacer | ||
reset-to-pull-request | ||
review | ||
run-dev.py | ||
run-mypy | ||
run-tsc | ||
run-yarn-deduplicate | ||
setup-git-repo | ||
show-profile-results | ||
stop-run-dev | ||
test-all | ||
test-api | ||
test-backend | ||
test-documentation | ||
test-emoji-name-scripts | ||
test-help-documentation | ||
test-js-with-casper | ||
test-js-with-node | ||
test-locked-requirements | ||
test-migrations | ||
test-queue-worker-reload | ||
test-run-dev | ||
test-tools | ||
update-authors-json | ||
update-locked-requirements | ||
update-prod-static | ||
update-zuliprc-api-field | ||
webpack | ||
webpack-helpers.ts | ||
webpack.assets.json | ||
webpack.config.ts | ||
zanitizer | ||
zanitizer_config.pm.sample |
README.md
This directory contains scripts that are used in building, managing,
testing, and other forms of work in a Zulip development environment.
Note that tools that are also useful in production belong in
scripts/
or should be Django management commands.
For more details, see https://zulip.readthedocs.io/en/latest/overview/directory-structure.html.