Skip to content

Commit

Permalink
then should be called explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
ackava committed Aug 23, 2024
1 parent 07fdbab commit 7786a8f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
3 changes: 1 addition & 2 deletions src/ci/certs/ParsePkcs12.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ export async function ParsePkcs12 ({
const p12 = forge.pkcs12.pkcs12FromAsn1(p12Asn1, certPass);
const bag = p12.safeContents.find((x) => x.encrypted).safeBags[0].attributes;
const friendlyName = bag.friendlyName[0];

return { friendlyName, p12 };
await then?.({ friendlyName, p12 });
}
10 changes: 5 additions & 5 deletions src/ci/mac/Security.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ export const Security = {
then = void 0 as ({ friendlyName, p12 } ) => any
}) {
return <Batch>
<ParsePkcs12
certPath={certPath}
certPass={certPass}
then={then}
/>
<Run
cmd="security"
args={["import", certPath,
Expand Down Expand Up @@ -87,6 +82,11 @@ export const Security = {
"-s", keychainPath
]}
/>
<ParsePkcs12
certPath={certPath}
certPass={certPass}
then={then}
/>
</Batch>
}

Expand Down
6 changes: 2 additions & 4 deletions src/core/XNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class XNode {

async execute() {
const a = this.attributes ?? {};
const { then, failed, throwOnFail = true} = a;
const { failed, throwOnFail = true} = a;
let result;
if (this.log) {
console.log(`Executing ${this.name.name} at ${this.attributes?.location}`);
Expand All @@ -32,11 +32,10 @@ export default class XNode {
}
try {
result = await this.___invoke(a);
await then?.(result);
} catch (error) {
failed?.(error);
if (throwOnFail) {
throw new (Error as any)(`Failed on ${this.attributes?.location}`, { cause: error });
throw new (Error as any)(`Failed ${this.name.name} on ${this.attributes?.location}`, { cause: error });
}
}
return result;
Expand All @@ -46,7 +45,6 @@ export default class XNode {
const result = this.name(a, ... this.children);
if (result?.[isXNode]) {
const ra = (result.attributes ??= {});
ra.then ??= a.then;
ra.failed ??= a.failed;
ra.throwOnFail ??= a.throwOnFail;
result.log = this.log;
Expand Down
10 changes: 6 additions & 4 deletions src/utils/FileSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ export const FileSystem = {
},

async ReadJson({
path
path,
then
}: ThenTaskArgs<IFileArg>) {
path = FileSystem.expand(path);
const text = await readFile(path, "utf8");
return JSON.parse(text);
await then?.(JSON.parse(text));
},

async WriteJson({
Expand All @@ -54,7 +55,8 @@ export const FileSystem = {

async MergeJson({
path,
json
json,
then
}: TaskArgs<{ path: string; json: any; }>) {
path = FileSystem.expand(path);
let existing = {};
Expand All @@ -68,7 +70,7 @@ export const FileSystem = {
existing = mergeJson(existing, json);
}
await writeFile(path, JSON.stringify(existing, void 0, 2));
return existing;
await then?.(existing);
}

};
Expand Down

0 comments on commit 7786a8f

Please sign in to comment.