Browse Source

rename helpers

Joe Caulfield 11 months ago
parent
commit
06b17bcb53
3 changed files with 10 additions and 27 deletions
  1. 2 19
      scripts/helpers/utils.mts
  2. 4 4
      scripts/js.mts
  3. 4 4
      scripts/rust.mts

+ 2 - 19
scripts/helpers/utils.mts

@@ -119,7 +119,7 @@ export function partitionArguments(
     : [args, []];
 }
 
-export function partitionArgumentsV2(
+export function partitionArgumentsWithDefaultArgs(
   args: string[],
   delimiter: string,
   defaultArgs?: string[],
@@ -144,24 +144,7 @@ export async function getInstalledSolanaVersion(): Promise<string | undefined> {
   }
 }
 
-export function parseCliArguments(): { manifestPath: string; args: string[] } {
-  // Command-line arguments.
-  const args = cliArguments();
-  // Extract the relative crate directory from the command-line arguments. This
-  // is the only required argument.
-  const relativePath = args.shift();
-
-  if (!relativePath) {
-    throw new Error('Missing relative manifest path');
-  }
-
-  return {
-    manifestPath: path.join(workingDirectory, relativePath, 'Cargo.toml'),
-    args,
-  };
-}
-
-export function parseCliArgumentsV2(): { command: string, libraryPath: string; args: string[] } {
+export function parseCliArguments(): { command: string, libraryPath: string; args: string[] } {
   const command = process.argv[2];
   const args = process.argv.slice(3);
   

+ 4 - 4
scripts/js.mts

@@ -4,8 +4,8 @@
 
 import 'zx/globals';
 import {
-    parseCliArgumentsV2,
-    partitionArgumentsV2,
+    parseCliArguments,
+    partitionArgumentsWithDefaultArgs,
 } from './helpers/utils.mts';
 
 enum Command {
@@ -15,13 +15,13 @@ enum Command {
     Publish = 'publish',
 }
 
-const { command, libraryPath, args } = parseCliArgumentsV2();
+const { command, libraryPath, args } = parseCliArguments();
 
 async function pnpm(
     command: string,
     build = false,
 ) {
-    const [pnpmArgs, commandArgs] = partitionArgumentsV2(args, '--');
+    const [pnpmArgs, commandArgs] = partitionArgumentsWithDefaultArgs(args, '--');
     cd(libraryPath);
     await $`pnpm install`;
     if (build) {

+ 4 - 4
scripts/rust.mts

@@ -6,8 +6,8 @@ import 'zx/globals';
 import {
     getCargo,
     getToolchainArgument,
-    parseCliArgumentsV2,
-    partitionArgumentsV2,
+    parseCliArguments,
+    partitionArgumentsWithDefaultArgs,
     popArgument,
     workingDirectory,
 } from './helpers/utils.mts';
@@ -23,7 +23,7 @@ enum Command {
     Publish = 'publish',
 }
 
-const { command, libraryPath, args } = parseCliArgumentsV2();
+const { command, libraryPath, args } = parseCliArguments();
 const manifestPath = path.join(libraryPath, 'Cargo.toml');
 
 async function cargo(
@@ -32,7 +32,7 @@ async function cargo(
     defaultArgs?: string[],
     variables?: [string, string][],
 ) {
-    const [cargoArgs, commandArgs] = partitionArgumentsV2(args, '--', defaultArgs);
+    const [cargoArgs, commandArgs] = partitionArgumentsWithDefaultArgs(args, '--', defaultArgs);
     variables?.forEach(([k, v]) => $.env[k] = v);
     await $`cargo ${toolchain} ${command} --manifest-path ${manifestPath} ${cargoArgs} -- ${commandArgs}`;
 }