lint.mjs 781 B

1234567891011121314151617181920212223242526272829
  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. await Promise.all(
  17. getProgramFolders().map(async (folder) => {
  18. const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml');
  19. if (fix) {
  20. await $`cargo ${toolchain} clippy --manifest-path ${manifestPath} --fix ${lintArgs}`;
  21. } else {
  22. await $`cargo ${toolchain} clippy --manifest-path ${manifestPath} ${lintArgs}`;
  23. }
  24. })
  25. );