Skip to content

Commit a52c6a7

Browse files
authored
Optimize time zone question (#69)
1 parent 2880c7a commit a52c6a7

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

installer/OptionalPackages.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,18 @@ public function installHyperfScript()
124124
$ask[] = "\n <question>What time zone do you want to setup ?</question>\n";
125125
$ask[] = " [<comment>n</comment>] Default time zone for php.ini\n";
126126
$ask[] = "Make your selection or type a time zone name, like Asia/Shanghai (n):\n";
127-
$answer = $this->io->ask(implode('', $ask), 'n');
127+
$answer = $this->io->askAndValidate(
128+
implode('', $ask),
129+
function ($value) {
130+
if ($value === 'y' || $value === 'yes') {
131+
throw new \InvalidArgumentException("You should type a time zone name, like Asia/Shanghai. Or type n to skip.");
132+
}
133+
134+
return $value;
135+
},
136+
null,
137+
'n'
138+
);
128139

129140
$content = file_get_contents($this->installerSource . '/resources/bin/hyperf.stub');
130141
if ($answer != 'n') {

0 commit comments

Comments
 (0)