mirror of
https://github.com/godotengine/godot-team-reports.git
synced 2025-12-31 13:48:17 +03:00
31 lines
769 B
JavaScript
31 lines
769 B
JavaScript
import { promises as fs } from 'fs';
|
|
|
|
import posthtml from 'posthtml';
|
|
import include from './posthtml-include';
|
|
import { green } from 'colorette';
|
|
|
|
export default function(options = {}) {
|
|
return {
|
|
name: 'posthtml',
|
|
buildEnd: async () => {
|
|
if (!options.src || !options.dest) {
|
|
return;
|
|
}
|
|
const html = await fs.readFile(options.src, { encoding: 'utf-8' });
|
|
|
|
const plugins = [
|
|
include({
|
|
root: './src'
|
|
})
|
|
];
|
|
const result = await posthtml(plugins).process(html);
|
|
|
|
try {
|
|
await fs.unlink(options.dest);
|
|
} catch (exc) { }
|
|
|
|
await fs.writeFile(options.dest, result.html, { encoding: 'utf-8' });
|
|
console.log(green(`written html template ${options.dest}`))
|
|
}
|
|
};
|
|
} |