Skip to content

Commit 7ca6b49

Browse files
committed
Use loop
1 parent ed12c48 commit 7ca6b49

File tree

4 files changed

+28
-36
lines changed

4 files changed

+28
-36
lines changed

template/base/scripts/program/build.mjs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ import './dump.mjs';
1414
const buildArgs = cliArguments();
1515

1616
// Build the programs.
17-
await Promise.all(
18-
getProgramFolders().map(async (folder) => {
19-
const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml');
17+
for (const folder of getProgramFolders()) {
18+
const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml');
2019

21-
await $`cargo-build-sbf --manifest-path ${manifestPath} ${buildArgs}`;
22-
})
23-
);
20+
await $`cargo-build-sbf --manifest-path ${manifestPath} ${buildArgs}`;
21+
}

template/base/scripts/program/format.mjs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@ const [cargoArgs, fmtArgs] = partitionArguments(formatArgs, '--');
1818
const toolchain = getToolchainArgument('format');
1919

2020
// Format the programs.
21-
await Promise.all(
22-
getProgramFolders().map(async (folder) => {
23-
const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml');
21+
for (const folder of getProgramFolders()) {
22+
const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml');
2423

25-
if (fix) {
26-
await $`cargo ${toolchain} fmt --manifest-path ${manifestPath} ${cargoArgs} -- ${fmtArgs}`;
27-
} else {
28-
await $`cargo ${toolchain} fmt --manifest-path ${manifestPath} ${cargoArgs} -- --check ${fmtArgs}`;
29-
}
30-
})
31-
);
24+
if (fix) {
25+
await $`cargo ${toolchain} fmt --manifest-path ${manifestPath} ${cargoArgs} -- ${fmtArgs}`;
26+
} else {
27+
await $`cargo ${toolchain} fmt --manifest-path ${manifestPath} ${cargoArgs} -- --check ${fmtArgs}`;
28+
}
29+
}

template/base/scripts/program/lint.mjs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@ const fix = popArgument(lintArgs, '--fix');
1616
const toolchain = getToolchainArgument('lint');
1717

1818
// Lint the programs using clippy.
19-
await Promise.all(
20-
getProgramFolders().map(async (folder) => {
21-
const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml');
19+
for (const folder of getProgramFolders()) {
20+
const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml');
2221

23-
if (fix) {
24-
await $`cargo ${toolchain} clippy --manifest-path ${manifestPath} --fix ${lintArgs}`;
25-
} else {
26-
await $`cargo ${toolchain} clippy --manifest-path ${manifestPath} ${lintArgs}`;
27-
}
28-
})
29-
);
22+
if (fix) {
23+
await $`cargo ${toolchain} clippy --manifest-path ${manifestPath} --fix ${lintArgs}`;
24+
} else {
25+
await $`cargo ${toolchain} clippy --manifest-path ${manifestPath} ${lintArgs}`;
26+
}
27+
}

template/base/scripts/program/test.mjs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@ const testArgs = cliArguments();
1616
const hasSolfmt = await which('solfmt', { nothrow: true });
1717

1818
// Test the programs.
19-
await Promise.all(
20-
getProgramFolders().map(async (folder) => {
21-
const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml');
19+
for (const folder of getProgramFolders()) {
20+
const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml');
2221

23-
if (hasSolfmt) {
24-
await $`RUST_LOG=error cargo test-sbf --manifest-path ${manifestPath} ${testArgs} 2>&1 | solfmt`;
25-
} else {
26-
await $`RUST_LOG=error cargo test-sbf --manifest-path ${manifestPath} ${testArgs}`;
27-
}
28-
})
29-
);
22+
if (hasSolfmt) {
23+
await $`RUST_LOG=error cargo test-sbf --manifest-path ${manifestPath} ${testArgs} 2>&1 | solfmt`;
24+
} else {
25+
await $`RUST_LOG=error cargo test-sbf --manifest-path ${manifestPath} ${testArgs}`;
26+
}
27+
}

0 commit comments

Comments
 (0)