git ssb

2+

cel / scuttlebot.io



Tree: 13691e1ee2bb8b8cec137e18d9f495648fba6793

Files: 13691e1ee2bb8b8cec137e18d9f495648fba6793 / index.js

1286 bytesRaw
1var jetpack = require('fs-jetpack')
2
3var tmpl = jetpack.cwd('tmpl')
4var build = jetpack.cwd('build')
5
6// iterate ./tmpl tree
7// run any template scripts (.html.js and .css.js)
8// and output the result to ./build (.html and .css)
9// ignore any partials (.part.js)
10// copy all other files
11tmpl.find('.', { matching: '*' }, 'inspect')
12 .forEach(entry => {
13 // console.log(entry)
14 if (entry.type == 'dir') {
15 // copy folder structure
16 // console.log('copying directory')
17 build.dir(entry.relativePath)
18 } else if (entry.type == 'file') {
19 if (entry.name.indexOf('.html.js') !== -1 || entry.name.indexOf('.css.js') !== -1) {
20 // build html/css files
21 // console.log('building')
22 buildTemplate(entry)
23 } else if (entry.name.indexOf('.part.js') !== -1) {
24 // skip partials
25 // console.log('skipping')
26 return
27 } else {
28 // copy all others
29 // console.log('copying', entry.absolutePath, entry.relativePath)
30 jetpack.copy(entry.absolutePath, build.path(entry.relativePath), { overwrite: true })
31 }
32 }
33 })
34
35function buildTemplate (entry) {
36 var template = require(entry.absolutePath)
37 var path = entry.relativePath.slice(0, -3) // remove the '.js'
38 build.write(path, template())
39}

Built with git-ssb-web