@kirigami/php-prepros 1.6.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kirigami/php-prepros",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "PHP preprocessor for the Kirigami static site generator. Compile PHP page templates to clean, deployable HTML — with zero server dependency.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"kirigami",
|
|
@@ -232,7 +232,11 @@ final class PREPROS
|
|
|
232
232
|
|
|
233
233
|
public static function getExportedFiles(): array
|
|
234
234
|
{
|
|
235
|
-
|
|
235
|
+
// array_unique() keeps the original keys, so any duplicate leaves a gap
|
|
236
|
+
// in the sequence — json_encode() would then emit a JSON object instead
|
|
237
|
+
// of an array and the JS side chokes ("retobj.files.map is not a
|
|
238
|
+
// function"). array_values() reindexes so it always serialises as a list.
|
|
239
|
+
$files = array_values(array_unique(self::$files));
|
|
236
240
|
// sort($files);
|
|
237
241
|
return $files;
|
|
238
242
|
}
|
package/src/prepros.js
CHANGED
|
@@ -151,6 +151,9 @@ const run = async (args = [], script = null, mountfiles = []) => {
|
|
|
151
151
|
const buffer = php.readFileAsBuffer(resultPath);
|
|
152
152
|
retobj = JSON.parse(Buffer.from(buffer).toString('utf8'));
|
|
153
153
|
retobj.debug = stdout;
|
|
154
|
+
// json_encode() turns a PHP array with gaps in its integer keys
|
|
155
|
+
// into an object — normalise back to a list before we map over it.
|
|
156
|
+
if (retobj.files && !Array.isArray(retobj.files)) retobj.files = Object.values(retobj.files);
|
|
154
157
|
if(retobj.files) await Promise.all(retobj.files.map(async (file, i) => {
|
|
155
158
|
const fbuffer = php.readFileAsBuffer(file);
|
|
156
159
|
const dest = file.replace(/^\/project\//i, '');
|