From 4bf00ae5ea71bcb3fcb6f46ae3608618e9d6dd8c Mon Sep 17 00:00:00 2001 From: skidu Date: Tue, 24 Jan 2017 16:47:12 +0800 Subject: [PATCH] =?UTF-8?q?mkdir=E9=94=99=E8=AF=AF=E6=8A=91=E5=88=B6=20?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E7=9B=AE=E5=BD=95=E5=A2=9E=E5=8A=A0gitignore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Commands/BaseCommand.php | 11 +++++++---- src/Commands/CreateCommand.php | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Commands/BaseCommand.php b/src/Commands/BaseCommand.php index 93213d2..f48c2d2 100644 --- a/src/Commands/BaseCommand.php +++ b/src/Commands/BaseCommand.php @@ -47,23 +47,26 @@ protected function initPidFile($pidFile=null) protected function initRunConfFile() { $runConfFile = config('workerman.run_conf'); - $this->createRunFile($runConfFile, 'runtime config file'); + $this->createRunFile($runConfFile, 'runtime config file', true); $this->runConfFile = $runConfFile; return true; } - private function createRunFile($file, $type) + private function createRunFile($file, $type, $ignore=false) { $directory = dirname($file); - if (!is_dir($directory) && !mkdir($directory)) { + if (!is_dir($directory) && !@mkdir($directory)) { throw new \Exception("can not create directory: {$directory}"); } - if (!is_file($file) && ! touch($file)) { + if (!is_file($file) && !touch($file)) { throw new \Exception("create {$type} failed: {$file}"); } if (!is_writable($file)) { throw new \Exception("{$type} can not been written: {$file}"); } + if(!is_file($directory.'/.gitignore')) { + file_put_contents($directory.'/.gitignore', '*'); + } return true; } diff --git a/src/Commands/CreateCommand.php b/src/Commands/CreateCommand.php index 051a57a..cc286fc 100644 --- a/src/Commands/CreateCommand.php +++ b/src/Commands/CreateCommand.php @@ -11,7 +11,7 @@ public function fire() $workerName = $this->argument('name'); $config = config('workerman'); $appPath = $config['app_path']; - if (!is_dir($appPath) && !mkdir($appPath)) { + if (!is_dir($appPath) && !@mkdir($appPath)) { throw new \Exception("create app directory failed: {$appPath}"); } @@ -19,7 +19,7 @@ public function fire() if (is_dir($workspace)) { throw new \Exception("directory exists: {$workspace}"); } - if (!mkdir($workspace)) { + if (!@mkdir($workspace)) { throw new \Exception("create app directory failed: {$workspace}"); }