123456789101112131415161718192021222324 |
- #!/usr/bin/env zx
- import 'zx/globals';
- import {
- cliArguments,
- getToolchainArgument,
- partitionArguments,
- popArgument,
- workingDirectory,
- } from '../utils.mjs';
- const [folder, ...formatArgs] = cliArguments();
- const fix = popArgument(formatArgs, '--fix');
- const [cargoArgs, fmtArgs] = partitionArguments(formatArgs, '--');
- const toolchain = getToolchainArgument('format');
- const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml');
- // Format the client.
- if (fix) {
- await $`cargo ${toolchain} fmt --manifest-path ${manifestPath} ${cargoArgs} -- ${fmtArgs}`;
- } else {
- await $`cargo ${toolchain} fmt --manifest-path ${manifestPath} ${cargoArgs} -- --check ${fmtArgs}`;
- }
|