Skip to content

Commit

Permalink
Scripts: ASA always loads only once
Browse files Browse the repository at this point in the history
  • Loading branch information
Invertisment committed Sep 4, 2020
1 parent 4fc7a99 commit 5bc073c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
20 changes: 10 additions & 10 deletions packages/algob/src/builtin-tasks/run.ts
Expand Up @@ -20,7 +20,7 @@ import {
lsScriptsDir,
scriptsDirectory
} from "../lib/script-checkpoints";
import { AlgobDeployer, AlgobRuntimeEnv, CheckpointRepo } from "../types";
import { AlgobDeployer, AlgobRuntimeEnv, ASADefs, CheckpointRepo } from "../types";
import { TASK_RUN } from "./task-names";

interface Input {
Expand All @@ -35,12 +35,13 @@ function mkDeployer (
runtimeEnv: AlgobRuntimeEnv,
cpData: CheckpointRepo,
allowWrite: boolean,
algoOp: AlgoOperator
algoOp: AlgoOperator,
asaDefs: ASADefs
): AlgobDeployer {
const deployer = new AlgobDeployerImpl(
runtimeEnv,
cpData,
loadASAFile(),
asaDefs,
algoOp);
if (allowWrite) {
return deployer;
Expand Down Expand Up @@ -86,15 +87,15 @@ export async function runMultipleScripts (
allowWrite: boolean,
algoOp: AlgoOperator
): Promise<void> {
const asaDefs = loadASAFile();
for (const scriptsBatch of batchScriptNames(scriptNames)) {
await runScriptsBatch(
runtimeEnv,
scriptsBatch,
onSuccessFn,
force,
logDebugTag,
allowWrite,
algoOp
(cpData: CheckpointRepo) => mkDeployer(runtimeEnv, cpData, allowWrite, algoOp, asaDefs)
);
}
}
Expand All @@ -105,13 +106,12 @@ async function runScriptsBatch (
scriptNames: string[],
onSuccessFn: (cpData: CheckpointRepo, relativeScriptPath: string) => void,
force: boolean,
logTag: string,
allowWrite: boolean,
algoOp: AlgoOperator
logDebugTag: string,
mkDeployerFn: (cpData: CheckpointRepo) => AlgobDeployer
): Promise<void> {
const log = debug(logTag);
const log = debug(logDebugTag);
const cpData: CheckpointRepo = loadCheckpointsRecursive();
const deployer: AlgobDeployer = mkDeployer(runtimeEnv, cpData, allowWrite, algoOp);
const deployer: AlgobDeployer = mkDeployerFn(cpData);

const scriptsFromScriptsDir: string[] = lsScriptsDir();

Expand Down
8 changes: 4 additions & 4 deletions packages/algob/src/internal/util/lists.ts
Expand Up @@ -7,10 +7,10 @@ function getLastSubchild<T> (ts: T[][]): T {
return getLast(getLast(ts));
}

export function partitionByFn (
f: (s: string, s1: string) => boolean,
input: string[]
): string[][] {
export function partitionByFn<T> (
f: (s: T, s1: T) => boolean,
input: T[]
): T[][] {
if (input.length === 0) {
return [];
}
Expand Down

0 comments on commit 5bc073c

Please sign in to comment.