فهرست منبع

Merge pull request #96 from solana-program/febo/loop

Fernando Otero 1 سال پیش
والد
کامیت
64aa0f9a6e

+ 5 - 0
.changeset/mean-ducks-lick.md

@@ -0,0 +1,5 @@
+---
+"create-solana-program": patch
+---
+
+Use loop on program scripts

+ 4 - 6
template/base/scripts/program/build.mjs

@@ -14,10 +14,8 @@ import './dump.mjs';
 const buildArgs = cliArguments();
 
 // Build the programs.
-await Promise.all(
-  getProgramFolders().map(async (folder) => {
-    const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml');
+for (const folder of getProgramFolders()) {
+  const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml');
 
-    await $`cargo-build-sbf --manifest-path ${manifestPath} ${buildArgs}`;
-  })
-);
+  await $`cargo-build-sbf --manifest-path ${manifestPath} ${buildArgs}`;
+}

+ 8 - 10
template/base/scripts/program/format.mjs

@@ -18,14 +18,12 @@ const [cargoArgs, fmtArgs] = partitionArguments(formatArgs, '--');
 const toolchain = getToolchainArgument('format');
 
 // Format the programs.
-await Promise.all(
-  getProgramFolders().map(async (folder) => {
-    const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml');
+for (const folder of getProgramFolders()) {
+  const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml');
 
-    if (fix) {
-      await $`cargo ${toolchain} fmt --manifest-path ${manifestPath} ${cargoArgs} -- ${fmtArgs}`;
-    } else {
-      await $`cargo ${toolchain} fmt --manifest-path ${manifestPath} ${cargoArgs} -- --check ${fmtArgs}`;
-    }
-  })
-);
+  if (fix) {
+    await $`cargo ${toolchain} fmt --manifest-path ${manifestPath} ${cargoArgs} -- ${fmtArgs}`;
+  } else {
+    await $`cargo ${toolchain} fmt --manifest-path ${manifestPath} ${cargoArgs} -- --check ${fmtArgs}`;
+  }
+}

+ 8 - 10
template/base/scripts/program/lint.mjs

@@ -16,14 +16,12 @@ const fix = popArgument(lintArgs, '--fix');
 const toolchain = getToolchainArgument('lint');
 
 // Lint the programs using clippy.
-await Promise.all(
-  getProgramFolders().map(async (folder) => {
-    const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml');
+for (const folder of getProgramFolders()) {
+  const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml');
 
-    if (fix) {
-      await $`cargo ${toolchain} clippy --manifest-path ${manifestPath} --fix ${lintArgs}`;
-    } else {
-      await $`cargo ${toolchain} clippy --manifest-path ${manifestPath} ${lintArgs}`;
-    }
-  })
-);
+  if (fix) {
+    await $`cargo ${toolchain} clippy --manifest-path ${manifestPath} --fix ${lintArgs}`;
+  } else {
+    await $`cargo ${toolchain} clippy --manifest-path ${manifestPath} ${lintArgs}`;
+  }
+}

+ 8 - 10
template/base/scripts/program/test.mjs

@@ -16,14 +16,12 @@ const testArgs = cliArguments();
 const hasSolfmt = await which('solfmt', { nothrow: true });
 
 // Test the programs.
-await Promise.all(
-  getProgramFolders().map(async (folder) => {
-    const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml');
+for (const folder of getProgramFolders()) {
+  const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml');
 
-    if (hasSolfmt) {
-      await $`RUST_LOG=error cargo test-sbf --manifest-path ${manifestPath} ${testArgs} 2>&1 | solfmt`;
-    } else {
-      await $`RUST_LOG=error cargo test-sbf --manifest-path ${manifestPath} ${testArgs}`;
-    }
-  })
-);
+  if (hasSolfmt) {
+    await $`RUST_LOG=error cargo test-sbf --manifest-path ${manifestPath} ${testArgs} 2>&1 | solfmt`;
+  } else {
+    await $`RUST_LOG=error cargo test-sbf --manifest-path ${manifestPath} ${testArgs}`;
+  }
+}