lint.mjs 742 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/env zx
  2. import 'zx/globals';
  3. import {
  4. cliArguments,
  5. getProgramFolders,
  6. getToolchainArgument,
  7. popArgument,
  8. workingDirectory,
  9. } from '../utils.mjs';
  10. // Configure additional arguments here, e.g.:
  11. // ['--arg1', '--arg2', ...cliArguments()]
  12. const lintArgs = cliArguments();
  13. const fix = popArgument(lintArgs, '--fix');
  14. const toolchain = getToolchainArgument('lint');
  15. // Lint the programs using clippy.
  16. for (const folder of getProgramFolders()) {
  17. const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml');
  18. if (fix) {
  19. await $`cargo ${toolchain} clippy --manifest-path ${manifestPath} --fix ${lintArgs}`;
  20. } else {
  21. await $`cargo ${toolchain} clippy --manifest-path ${manifestPath} ${lintArgs}`;
  22. }
  23. }