Skip to content

Commit

Permalink
增加appDir的判断
Browse files Browse the repository at this point in the history
  • Loading branch information
yunwuxin committed Dec 1, 2016
1 parent ae50760 commit 4c6e1eb
Showing 1 changed file with 27 additions and 18 deletions.
45 changes: 27 additions & 18 deletions src/ThinkExtend.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,39 @@ public function update(InstalledRepositoryInterface $repo, PackageInterface $ini

protected function copyExtraFiles(PackageInterface $package)
{
$extra = $package->getExtra();
if ($this->composer->getPackage()->getType() == 'project') {

if (!empty($extra['think-config'])) {
$extra = $package->getExtra();

$composerExtra = $this->composer->getPackage()->getExtra();
$extraDir = (!empty($composerExtra['app-path']) ? $composerExtra['app-path'] : 'application') . DIRECTORY_SEPARATOR . 'extra';
$this->filesystem->ensureDirectoryExists($extraDir);
if (!empty($extra['think-config'])) {

//配置文件
foreach ((array) $extra['think-config'] as $name => $config) {
$target = $extraDir . DIRECTORY_SEPARATOR . $name . '.php';
$source = $this->getInstallPath($package) . DIRECTORY_SEPARATOR . $config;
$composerExtra = $this->composer->getPackage()->getExtra();

if (is_file($target)) {
$this->io->write("<info>File {$target} exist!</info>");
continue;
}
$appDir = !empty($composerExtra['app-path']) ? $composerExtra['app-path'] : 'application';

if (!is_file($source)) {
$this->io->write("<info>File {$target} not exist!</info>");
continue;
}
if (is_dir($appDir)) {

$extraDir = $appDir . DIRECTORY_SEPARATOR . 'extra';
$this->filesystem->ensureDirectoryExists($extraDir);

//配置文件
foreach ((array) $extra['think-config'] as $name => $config) {
$target = $extraDir . DIRECTORY_SEPARATOR . $name . '.php';
$source = $this->getInstallPath($package) . DIRECTORY_SEPARATOR . $config;

copy($source, $target);
if (is_file($target)) {
$this->io->write("<info>File {$target} exist!</info>");
continue;
}

if (!is_file($source)) {
$this->io->write("<info>File {$target} not exist!</info>");
continue;
}

copy($source, $target);
}
}
}
}
}
Expand Down

0 comments on commit 4c6e1eb

Please sign in to comment.