You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
465 B
24 lines
465 B
import { TemplateEngine } from './index.js'; |
|
import { basename } from 'node:path'; |
|
|
|
// Check arguments |
|
if (process.argv.length !== 3) { |
|
console.error(`Usage: node ${basename(process.argv[1])} filename`); |
|
process.exit(1); |
|
} |
|
const fileName = process.argv[2]; |
|
|
|
const tp = new TemplateEngine(); |
|
|
|
let result; |
|
|
|
try { |
|
result = await tp.render(fileName); |
|
} catch (e) { |
|
console.error(e.message); |
|
process.exit(1); |
|
} |
|
|
|
if (result) { |
|
process.stdout.write(result); |
|
}
|
|
|