Skip to content
This repository was archived by the owner on Jan 17, 2025. It is now read-only.

Commit 600e006

Browse files
authored
Beautify generated action code (#53)
1 parent c9f7c24 commit 600e006

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

composer.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const os = require('os')
2323
const path = require('path')
2424
const util = require('util')
2525
const uglify = require('uglify-es')
26+
const { version } = require('./package.json')
2627

2728
class ComposerError extends Error {
2829
constructor(message, argument) {
@@ -46,7 +47,7 @@ function validate(options) {
4647
*/
4748
function encode({ name, action }) {
4849
if (action.exec.kind !== 'composition') return { name, action }
49-
const code = `${conductor}(eval,${JSON.stringify(action.exec.composition)})` // invoke conductor on composition
50+
const code = `// generated by composer v${version}\n\nconst composition = ${JSON.stringify(action.exec.composition, null, 4)}\n\n// do not edit below this point\n\n${conductor}(eval,composition)` // invoke conductor on composition
5051
return { name, action: { exec: { kind: 'nodejs:default', code }, annotations: [{ key: 'conductor', value: action.exec.composition }] } }
5152
}
5253

@@ -307,7 +308,7 @@ module.exports = new Composer()
307308

308309
// conductor action
309310

310-
const conductor = `const main=(${uglify.minify(`${init}`).code})`
311+
const conductor = `const main=(${uglify.minify(`${init}`, { output: { max_line_len: 127 } }).code})`
311312

312313
function init(__eval__, composition) {
313314
function chain(front, back) {

0 commit comments

Comments
 (0)