файл пакета→ .shtukbase/packages/live/actions/app.ts
actions/app.ts
21 строка, 1.1 КБ.
Файл как есть в пакете: код и комментарии в нём не переводятся.
- // Action `app [path.html]`: puts the example interactive page (a task board with buttons) into the project,
- // by default at work/tasks-app.html. An existing file is never overwritten.
- import { copyFileSync, existsSync, mkdirSync } from 'node:fs';
- import { dirname, join, resolve, sep } from 'node:path';
- const target = (process.argv[2] ?? 'work/tasks-app.html').replace(/^\/+/, '');
- const root = process.cwd();
- const file = resolve(root, target);
- if (!file.startsWith(root + sep) || !file.endsWith('.html')) {
- console.error(`path "${target}" does not fit: it must be an .html file inside the project`);
- process.exit(2);
- }
- if (existsSync(file)) {
- console.error(`${target} already exists: not overwriting`);
- process.exit(1);
- }
- mkdirSync(dirname(file), { recursive: true });
- copyFileSync(join(import.meta.dir, '..', 'templates', 'tasks-app.html'), file);
- console.log(`the example is in ${target}`);
- console.log('Open it through the live server link with the token: shtuk run live serve.');
- console.log('The "Check project" button needs the line "shtuk check" in run: of the page /base/live.md.');