• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Cecilapp / Cecil / 21900210283

11 Feb 2026 09:48AM UTC coverage: 77.124%. First build
21900210283

Pull #2313

github

web-flow
Merge 8a1111676 into ef8bfe522
Pull Request #2313: Parallelize page conversion using pcntl

79 of 129 new or added lines in 4 files covered. (61.24%)

3196 of 4144 relevant lines covered (77.12%)

0.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

36.36
/src/Step/Assets/Save.php
1
<?php
2

3
/**
4
 * This file is part of Cecil.
5
 *
6
 * (c) Arnaud Ligny <arnaud@ligny.fr>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace Cecil\Step\Assets;
15

16
use Cecil\Cache;
17
use Cecil\Exception\RuntimeException;
18
use Cecil\Step\AbstractStep;
19
use Cecil\Util;
20

21
/**
22
 * Save assets step.
23
 *
24
 * This step is responsible for saving assets to the output directory.
25
 * It copies files from the cache to the output directory, ensuring that
26
 * assets are available for the final build. If the cache is disabled, it
27
 * clears the cache directory before processing assets.
28
 */
29
class Save extends AbstractStep
30
{
31
    protected Cache $cache;
32

33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function getName(): string
37
    {
38
        return 'Saving assets';
1✔
39
    }
40

41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function init(array $options): void
45
    {
46
        // last build step: should clear cache?
47
        $this->clearCacheIfDisabled();
1✔
48

49
        if ($options['dry-run']) {
1✔
50
            return;
×
51
        }
52

53
        $this->cache = new Cache($this->builder, 'assets');
1✔
54

55
        $this->canProcess = true;
1✔
56
    }
57

58
    /**
59
     * {@inheritdoc}
60
     * Note: a file from `static/` with the same name will NOT be overridden.
61
     *
62
     * @throws RuntimeException
63
     */
64
    public function process(): void
65
    {
66
        $total = \count($this->builder->getAssetsList());
1✔
67
        if ($total > 0) {
1✔
68
            $count = 0;
×
69
            foreach ($this->builder->getAssetsList() as $path) {
×
70
                // if file deleted from assets cache
71
                if (!Util\File::getFS()->exists($this->cache->getContentFile($path))) {
×
72
                    $this->builder->getLogger()->warning(\sprintf('Asset "%s" not found in cache, skipping. You should clear all cache.', $path));
×
73
                    break;
×
74
                }
75
                $count++;
×
76
                Util\File::getFS()->copy($this->cache->getContentFile($path), Util::joinFile($this->config->getOutputPath(), $path), false);
×
77
                $message = \sprintf('Asset "%s" saved', $path);
×
78
                $this->builder->getLogger()->info($message, ['progress' => [$count, $total]]);
×
79
            }
NEW
80
            $this->builder->deleteAssetsList();
×
81
        }
82
    }
83

84
    /**
85
     * Deletes cache directory, if cache is disabled.
86
     */
87
    private function clearCacheIfDisabled(): void
88
    {
89
        if (!$this->config->isEnabled('cache')) {
1✔
90
            try {
91
                Util\File::getFS()->remove($this->config->getCachePath());
×
92
            } catch (\Exception) {
×
93
                throw new RuntimeException(\sprintf('Unable to remove cache directory "%s".', $this->config->getCachePath()));
×
94
            }
95
        }
96
    }
97
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc