|
|
@ -1,5 +1,6 @@ |
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
// Copyright 2022 Ivan Polyakov
|
|
|
|
// Copyright 2022 Ivan Polyakov
|
|
|
|
|
|
|
|
|
|
|
|
const { spawn } = require('child_process'); |
|
|
|
const { spawn } = require('child_process'); |
|
|
|
const { validate } = require('schema-utils'); |
|
|
|
const { validate } = require('schema-utils'); |
|
|
|
|
|
|
|
|
|
|
@ -14,6 +15,9 @@ const schema = { |
|
|
|
type: 'string', |
|
|
|
type: 'string', |
|
|
|
default: '<!DOCTYPE html>', |
|
|
|
default: '<!DOCTYPE html>', |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
afterTranslate: { |
|
|
|
|
|
|
|
instanceOf: 'Function', |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -35,7 +39,12 @@ module.exports = function(content, map, meta) { |
|
|
|
|
|
|
|
|
|
|
|
const cb = this.async(); |
|
|
|
const cb = this.async(); |
|
|
|
runScheme('guile', ['-c', expr]).then(data => { |
|
|
|
runScheme('guile', ['-c', expr]).then(data => { |
|
|
|
cb(null, `${doctype}\n${data}`, map, meta); |
|
|
|
let markup = `${doctype}\n${data}`; |
|
|
|
|
|
|
|
if (options.afterTranslate) { |
|
|
|
|
|
|
|
markup = options.afterTranslate(markup); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cb(null, markup, map, meta); |
|
|
|
}).catch(code => { |
|
|
|
}).catch(code => { |
|
|
|
console.error(`Guile exited with code ${code}`); |
|
|
|
console.error(`Guile exited with code ${code}`); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -45,15 +54,10 @@ function runScheme(interpreter, flags) { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
const scheme = spawn(interpreter, flags); |
|
|
|
const scheme = spawn(interpreter, flags); |
|
|
|
|
|
|
|
|
|
|
|
scheme.stdout.on('data', (data) => { |
|
|
|
scheme.stdout.on('data', resolve); |
|
|
|
resolve(data); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
scheme.stderr.on('data', (data) => { |
|
|
|
scheme.stderr.on('data', (data) => { |
|
|
|
console.error(data.toString()); |
|
|
|
console.error(data.toString()); |
|
|
|
}); |
|
|
|
}); |
|
|
|
scheme.on('exit', (code) => { |
|
|
|
scheme.on('exit', reject); |
|
|
|
if (code) |
|
|
|
|
|
|
|
reject(code); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|