Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Copyright (c) OWASP Foundation. All Rights Reserved.

import { Builders, Enums, Factories, Serialize, Spec, Validation } from '@cyclonedx/cyclonedx-library'
import { Argument, Command, Option } from 'commander'
import { existsSync, openSync } from 'fs'
import { existsSync, mkdirSync, openSync } from 'fs'
import { dirname, resolve } from 'path'

import { loadJsonFile, writeAllSync } from './_helpers'
Expand Down Expand Up @@ -307,12 +307,16 @@ export async function run (process: NodeJS.Process): Promise<number> {
}
}
}

const directory = dirname(options.outputFile)
if (!existsSync(directory)) {
Comment thread
jkowalleck marked this conversation as resolved.
myConsole.info('INFO | Creating directory ' + directory)
Comment thread
cuhland marked this conversation as resolved.
Outdated
mkdirSync(directory, { recursive: true })
}
myConsole.log('LOG | writing BOM to', options.outputFile)
const written = await writeAllSync(
options.outputFile === OutputStdOut
? process.stdout.fd
: openSync(resolve(process.cwd(), options.outputFile), 'w'),
Comment thread
jkowalleck marked this conversation as resolved.
: openSync(resolve(options.outputFile), 'w'),
Comment thread
cuhland marked this conversation as resolved.
Outdated
serialized
)
myConsole.info('INFO | wrote %d bytes to %s', written, options.outputFile)
Expand Down