1350 files changed
+197
-941995
No files matched your search
@@ -5,9 +5,9 @@
|
||||
* pixi run new-exercise my-thing
|
||||
* node scripts/new-exercise.mjs my-thing --title "My thing" --group "Loop forms" # with a title and group
|
||||
*
|
||||
* If mojo/local/my-thing.mojo already exists it is kept as written and only the
|
||||
* If library/mojo/local/my-thing.mojo already exists it is kept as written and only the
|
||||
* exercise is made, so you can start from a .mojo file. Otherwise it creates
|
||||
* mojo/local/my-thing.mojo a runnable skeleton with the header verify.py reads
|
||||
* library/mojo/local/my-thing.mojo a runnable skeleton with the header verify.py reads
|
||||
* src/exercises/my-thing.ts an exercise that names it (`mojoProgram`)
|
||||
* and registers the exercise in src/exercises/index.ts (before the demo playground,
|
||||
* which stays last). Then `pixi run play my-thing` runs it, checks it on godbolt,
|
||||
@@ -27,7 +27,7 @@ function die(msg) { console.error(`new: ${msg}`); process.exit(1); }
|
||||
if (!id) die('usage: pixi run new-exercise <id>\n or: node scripts/new-exercise.mjs <id> [--title "Title"] [--group "Home-page section"]\n <id> is lowercase words joined by hyphens, e.g. rolling-sum');
|
||||
if (!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(id)) die(`"${id}" is not a valid id: lowercase letters and digits, joined by single hyphens`);
|
||||
|
||||
const mojoPath = path.join(ROOT, 'mojo/local', `${id}.mojo`);
|
||||
const mojoPath = path.join(ROOT, 'library/mojo/local', `${id}.mojo`);
|
||||
const tsPath = path.join(ROOT, 'src/exercises', `${id}.ts`);
|
||||
const indexPath = path.join(ROOT, 'src/exercises/index.ts');
|
||||
// A .mojo file you already wrote is adopted as it is: only the exercise is made.
|
||||
@@ -59,7 +59,7 @@ fs.writeFileSync(tsPath, `import { exercise } from './types.js';
|
||||
|
||||
export default exercise({
|
||||
id: '${id}',
|
||||
mojoProgram: '${id}', // mojo/local/${id}.mojo; \`pixi run play ${id}\` runs, verifies and builds it
|
||||
mojoProgram: '${id}', // library/mojo/local/${id}.mojo; \`pixi run play ${id}\` runs, verifies and builds it
|
||||
title: ${JSON.stringify(title)},
|
||||
group: ${JSON.stringify(group)},
|
||||
blurb: 'One or two sentences: what the student does here and what they will notice.',
|
||||
@@ -72,4 +72,4 @@ export default exercise({
|
||||
index = index.replace(anchorImport, `import ${camel} from './${id}.js';\n${anchorImport}`).replace(anchorList, ` ${camel},\n blank,\n];`);
|
||||
fs.writeFileSync(indexPath, index);
|
||||
|
||||
console.log(`${adopt ? 'adopted ' : 'created '} mojo/local/${id}.mojo\ncreated src/exercises/${id}.ts\nupdated src/exercises/index.ts\n\nnext: pixi run play ${id}`);
|
||||
console.log(`${adopt ? 'adopted ' : 'created '} library/mojo/local/${id}.mojo\ncreated src/exercises/${id}.ts\nupdated src/exercises/index.ts\n\nnext: pixi run play ${id}`);
|
||||
Reference in new issue
Block a user