Skip to content

Commit

Permalink
feat: doctor checks for "set -e" in test scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Dec 7, 2024
1 parent 8a29693 commit 7b1d50a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/synthetic-chain/src/cli/doctor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,20 @@ import { ProposalInfo } from './proposals.js';
import assert from 'node:assert';
import { execSync } from 'node:child_process';

const checkTestScript = (proposalPath: string) => {
const testScript = path.join(proposalPath, 'test.sh');
if (fs.existsSync(testScript)) {
const content = fs.readFileSync(testScript, 'utf-8');
assert(
content.includes('set -e'),
'test.sh must include "set -e"; otherwise lines may fail silently. "set -euo pipefail" is recommended.',
);
}
};

const fixupProposal = (proposal: ProposalInfo) => {
const proposalPath = path.join('proposals', proposal.path);
checkTestScript(proposalPath);
const packageJson = JSON.parse(
fs.readFileSync(path.join(proposalPath, 'package.json'), 'utf-8'),
);
Expand Down

0 comments on commit 7b1d50a

Please sign in to comment.