Skip to content

Commit f8d508a

Browse files
xumapleclaude
andauthored
Fix pre-push hook crash from orphaned ci.yml updater (#484)
copy-shared-files.mjs rewrote a jobs.test-individual.strategy.matrix.project node in ci.yml that #461 removed, so it threw a TypeError on every push that changed a shared file or added a sample. The CI sample list is hand-maintained now, so drop the dead block and the two imports it was the sole user of. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 4287f1c commit f8d508a

1 file changed

Lines changed: 0 additions & 33 deletions

File tree

.scripts/copy-shared-files.mjs

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
// Run with https://github.com/google/zx
2-
const { readFileSync } = require('fs');
3-
42
const STORED_SAMPLES = new Set(require('./list-of-samples.json').samples);
53

6-
const yaml = require('yaml');
7-
84
const NON_SAMPLES = ['node_modules'];
95
const ADDITIONAL_SAMPLES = [];
106

@@ -201,35 +197,6 @@ for (const sample of samples) {
201197
await copyAndAdd(sample, '.nvmrc');
202198
}
203199

204-
process.stdout.write('Updating GitHub workflows...');
205-
206-
const ciConfig = yaml.parseDocument(await fs.readFile('.github/workflows/ci.yml', 'utf8'));
207-
const jobsNode = ciConfig.contents.items.find((i) => i.key.value === 'jobs');
208-
const testNode = jobsNode.value.items.find((i) => i.key.value === 'test-individual');
209-
const testProjectsNode = testNode.value.items
210-
.find((i) => i.key.value === 'strategy')
211-
.value.items.find((i) => i.key.value === 'matrix')
212-
.value.items.find((i) => i.key.value === 'project');
213-
214-
testProjectsNode.value.items = [];
215-
216-
for (const sample of samples) {
217-
// Don't use require, because it won't work with ESM samples
218-
const packageJson = JSON.parse(readFileSync(`./${sample}/package.json`));
219-
const hasTestScript = !!packageJson.scripts.test;
220-
221-
if (hasTestScript) {
222-
testProjectsNode.value.items.push(sample);
223-
} else {
224-
const index = testProjectsNode.value.items.indexOf(sample);
225-
if (index >= 0) {
226-
testProjectsNode.value.items.splice(index, 1);
227-
}
228-
}
229-
}
230-
231-
await fs.writeFile('.github/workflows/ci.yml', ciConfig.toString());
232-
233200
console.log(' done.');
234201

235202
async function copyAndAdd(sample, file) {

0 commit comments

Comments
 (0)