Skip to content

Commit d01e2ce

Browse files
committed
Fix #36 when a custom serverless.yml config file is passed
1 parent f74681f commit d01e2ce

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/Commands/ApplicationCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ protected function configure(): void
2323
* environmentName: string,
2424
* team: string,
2525
* config: array{name: string, team: string, type: string},
26+
* configFileName: string|null,
2627
* }
2728
*/
2829
protected function parseStandardOptions(InputInterface $input): array
@@ -38,6 +39,7 @@ protected function parseStandardOptions(InputInterface $input): array
3839
'config' => $config,
3940
'environmentName' => $environment,
4041
'team' => $config['team'],
42+
...['configFileName' => $configFileName],
4143
];
4244
}
4345
}

src/Components/ServerlessFramework.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ public function deploy(int $deploymentId, string $environment, array $awsCredent
3232
if ($input->hasOption('force')) {
3333
$options[] = '--force';
3434
}
35+
if ($input->hasOption('config') && $input->getOption('config')) {
36+
$configFile = (string) $input->getOption('config');
37+
$options[] = '--config';
38+
$options[] = $configFile;
39+
} else {
40+
$configFile = null;
41+
}
3542

3643
$newLogs = '';
3744
$entireSlsOutput = '';
@@ -89,7 +96,7 @@ public function deploy(int $deploymentId, string $environment, array $awsCredent
8996

9097
$hasChanges = ! str_contains($newLogs, 'No changes to deploy. Deployment skipped.');
9198
if ($hasChanges) {
92-
$outputs = $this->retrieveOutputs($environment, $awsCredentials);
99+
$outputs = $this->retrieveOutputs($environment, $awsCredentials, $configFile);
93100

94101
$region = $outputs['region'];
95102
$stackName = $outputs['stack'];
@@ -115,9 +122,15 @@ public function deploy(int $deploymentId, string $environment, array $awsCredent
115122
* @return array<string, string>
116123
* @throws Exception
117124
*/
118-
private function retrieveOutputs(string $environment, array $awsCredentials): array
125+
private function retrieveOutputs(string $environment, array $awsCredentials, ?string $configFile): array
119126
{
120-
$process = $this->serverlessExec('info', $environment, $awsCredentials, []);
127+
$options = [];
128+
if ($configFile) {
129+
$options[] = '--config';
130+
$options[] = $configFile;
131+
}
132+
133+
$process = $this->serverlessExec('info', $environment, $awsCredentials, $options);
121134
$process->join();
122135
$infoOutput = buffer($process->getStdout());
123136
// Remove non-ASCII characters

0 commit comments

Comments
 (0)