Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion src/commands/base-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ export type BaseOptionValues = {
filter?: string
httpProxy?: string
silent?: string
verbose?: boolean
}

/** Base command class that provides tracking and config initialization */
Expand Down Expand Up @@ -796,4 +797,4 @@ export default class BaseCommand extends Command {
}

export const getBaseOptionValues = (options: OptionValues): BaseOptionValues =>
pick(options, ['auth', 'cwd', 'debug', 'filter', 'httpProxy', 'silent'])
pick(options, ['auth', 'cwd', 'debug', 'filter', 'httpProxy', 'silent', 'verbose'])
10 changes: 9 additions & 1 deletion src/commands/deploy/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,15 @@ const handleBuild = async ({
const { configMutations, exitCode, newConfig, logs } = await runBuild(resolvedOptions)
// Without this, the deploy command fails silently
if (options.json && exitCode !== 0) {
const message = logs?.stderr.length ? `: ${logs.stderr.join('')}` : ''
let message = ''

if (options.verbose && logs?.stdout.length) {
message += `\n\n${logs.stdout.join('')}\n\n`
}

if (logs?.stderr.length) {
message += logs.stderr.join('')
}

logAndThrowError(`Error while running build${message}`)
}
Expand Down
4 changes: 4 additions & 0 deletions src/commands/deploy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ For more information about Netlify deploys, see ${terminalLink(docsUrl, docsUrl,
`
})
.action(async (options: DeployOptionValues, command: BaseCommand) => {
if (command.parent?.opts().verbose) {
options.verbose = true
}

if (options.build && command.getOptionValueSource('build') === 'cli') {
warn(`${chalk.cyanBright('--build')} is now the default and can safely be omitted.`)
}
Expand Down
28 changes: 28 additions & 0 deletions tests/integration/commands/deploy/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,34 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
})
})

test('should include stdout and stderr when build fails with --json --verbose options', async (t) => {
await withSiteBuilder(t, async (builder) => {
builder
.withContentFile({
path: 'public/index.html',
content: '<h1>Test content</h1>',
})
.withNetlifyToml({
config: {
build: {
publish: 'public',
command:
"node -e \"process.stdout.write('Build output'); process.stderr.write('Build error'); process.exit(1)\"",
},
},
})

await builder.build()

await expect(
callCli(['deploy', '--json', '--verbose'], {
cwd: builder.directory,
env: { NETLIFY_SITE_ID: context.siteId },
}),
).rejects.toThrow('Build output')
})
})

test('should deploy hidden public folder but ignore hidden/__MACOSX files', { retry: 3 }, async (t) => {
await withSiteBuilder(t, async (builder) => {
builder
Expand Down