Skip to content

Commit

Permalink
show compiled files
Browse files Browse the repository at this point in the history
  • Loading branch information
kla committed Aug 11, 2024
1 parent 760a4f6 commit 5559a48
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ program.command('compile')
.argument('<location>', 'Path to a Staxfile or directory with one')
.description('Compile a Staxfile')
.action(async location => {
new Compiler(location).compile()
new Compiler(location).compile(true)
})

program.command('setup')
Expand Down
9 changes: 8 additions & 1 deletion src/staxfile/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default class Compiler {
this.baseDir = path.dirname(path.resolve(this.staxfile))
}

public compile() {
public compile(print: boolean = false) {
const files = { dockerFile: undefined, composeFile: undefined }

this.insideBaseDir(() => {
Expand All @@ -27,6 +27,13 @@ export default class Compiler {
files.composeFile = new ComposeGenerator(this.config, { staxfile: this.staxfile, dockerfile: files.dockerFile })
.compile(this.tempFile('compose'))
})

if (print) {
console.log('# Dockerfile')
console.log(readFileSync(files.dockerFile, 'utf-8'))
console.log('# compose.yaml')
console.log(readFileSync(files.composeFile, 'utf-8'))
}
return files
}

Expand Down

0 comments on commit 5559a48

Please sign in to comment.