UNPKG

@matrixage/picpic

Version:

A awesome image bed by github pages and github actions.

46 lines (34 loc) 1.1 kB
const fs = require('fs-extra') const injectData = require('./injectData') const injectStyles = require('./injectStyles') const injectTemplates = require('./injectTemplates') const injectJs = require('./injectJs') const paths = require('../utils/paths') function Inject (){ this.html = '' this.getSource = () => { this.html = fs.readFileSync(paths.getPath('../../src/source.html')).toString() return new Promise(resolve => resolve(this.html)) } this.injectData = async () => { this.html = await injectData(this.html) return new Promise(resolve => resolve(this.html)) } this.injectStyles = async () => { this.html = await injectStyles(this.html) return new Promise(resolve => resolve(this.html)) } this.injectTemplates = async () => { this.html = await injectTemplates(this.html) return new Promise(resolve => resolve(this.html)) } } const inject = async () => { return await new Inject() .getSource() .then(res => injectData(res)) .then(res => injectStyles(res)) .then(res => injectTemplates(res)) .then(res => injectJs(res)) } module.exports = inject