Skip to content

Commit defbb03

Browse files
committed
refactor: do all argv parsing in createDeployCommand
This prevents us from loading the `deploy` command's full dependency tree when we know we can't service the user's request.
1 parent 70364c4 commit defbb03

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/commands/deploy/deploy.ts

-8
Original file line numberDiff line numberDiff line change
@@ -809,14 +809,6 @@ export const deploy = async (options: DeployOptionValues, command: BaseCommand)
809809

810810
command.setAnalyticsPayload({ open: options.open, prod: options.prod, json: options.json, alias: Boolean(alias) })
811811

812-
if (options.branch) {
813-
warn('--branch flag has been renamed to --alias and will be removed in future versions')
814-
}
815-
816-
if (options.context && !options.build) {
817-
return logAndThrowError('--context flag is only available when using the --build flag')
818-
}
819-
820812
await command.authenticate(options.auth)
821813

822814
let siteId = site.id || options.site

src/commands/deploy/index.ts

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { env } from 'process'
33
import { Option } from 'commander'
44

55
import BaseCommand from '../base-command.js'
6+
import { logAndThrowError, warn } from '../../utils/command-helpers.js'
67
import type { DeployOptionValues } from './option_values.js'
78

89
export const createDeployCommand = (program: BaseCommand) =>
@@ -127,6 +128,14 @@ Support for package.json's main field, and intrinsic index.js entrypoints are co
127128
'netlify deploy --build --context deploy-preview',
128129
])
129130
.action(async (options: DeployOptionValues, command: BaseCommand) => {
131+
if (options.branch) {
132+
warn('--branch flag has been renamed to --alias and will be removed in future versions')
133+
}
134+
135+
if (options.context && !options.build) {
136+
return logAndThrowError('--context flag is only available when using the --build flag')
137+
}
138+
130139
const { deploy } = await import('./deploy.js')
131140
await deploy(options, command)
132141
})

0 commit comments

Comments
 (0)