mirror of
https://github.com/samsonjs/samhuri.net.git
synced 2026-04-27 14:57:40 +00:00
fix blog builder
This commit is contained in:
parent
1bd690c08a
commit
2b6af02d8e
1 changed files with 16 additions and 12 deletions
28
build.js
28
build.js
|
|
@ -45,18 +45,22 @@ function main() {
|
||||||
function buildProject(name, project, ctx) {
|
function buildProject(name, project, ctx) {
|
||||||
var dir = path.join(__dirname, 'proj', name)
|
var dir = path.join(__dirname, 'proj', name)
|
||||||
, index = path.join(dir, 'index.html')
|
, index = path.join(dir, 'index.html')
|
||||||
fs.statSync(dir)
|
|
||||||
fs.mkdir(dir, 0775, function(err) {
|
try {
|
||||||
if (err && err.code !== 'EEXIST') throw err
|
fs.statSync(dir)
|
||||||
fs.unlink(index, function(err) {
|
}
|
||||||
if (err && err.code !== 'ENOENT') throw err
|
catch (e) {
|
||||||
project.name = name
|
fs.mkdirSync(dir, 0775)
|
||||||
fs.writeFile(index, mustache.to_html(ctx.template, project), function(err) {
|
}
|
||||||
if (err) console.error('error: ', err.message)
|
|
||||||
ctx.n -= 1
|
fs.unlink(index, function(err) {
|
||||||
console.log('* ' + name + (err ? ' (failed)' : ''))
|
if (err && err.code !== 'ENOENT') throw err
|
||||||
if (ctx.n === 0) console.log('done projects')
|
project.name = name
|
||||||
})
|
fs.writeFile(index, mustache.to_html(ctx.template, project), function(err) {
|
||||||
|
if (err) console.error('error: ', err.message)
|
||||||
|
ctx.n -= 1
|
||||||
|
console.log('* ' + name + (err ? ' (failed)' : ''))
|
||||||
|
if (ctx.n === 0) console.log('done projects')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue