Changeset 62157
- Timestamp:
- 03/27/2026 12:32:38 AM (32 hours ago)
- Location:
- trunk
- Files:
-
- 3 edited
-
package-lock.json (modified) (2 diffs)
-
package.json (modified) (1 diff)
-
tools/gutenberg/copy.js (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/package-lock.json
r62061 r62157 80 80 "install-changed": "1.1.0", 81 81 "json2php": "0.0.12", 82 "php-array-reader": "2.1.3", 82 83 "postcss": "8.5.8", 83 84 "prettier": "npm:wp-prettier@3.0.3", … … 26138 26139 "dev": true 26139 26140 }, 26141 "node_modules/php-array-reader": { 26142 "version": "2.1.3", 26143 "resolved": "https://registry.npmjs.org/php-array-reader/-/php-array-reader-2.1.3.tgz", 26144 "integrity": "sha512-FjgMmNfnbi76wsbzO/dWEeySt0WZpxv8q/7RH0XFPyNLxsfJSf97KKe/4Rgdmx/XRDGlbl8THU5ayKwGE3Xqrw==", 26145 "dev": true, 26146 "license": "MIT", 26147 "dependencies": { 26148 "php-parser": "^3.1.5" 26149 } 26150 }, 26151 "node_modules/php-parser": { 26152 "version": "3.5.0", 26153 "resolved": "https://registry.npmjs.org/php-parser/-/php-parser-3.5.0.tgz", 26154 "integrity": "sha512-EHdzSckQNP86jQRCEsMYhs+YzS4BfvfxnyhvzHVhVRoRUGEMFi8f3xKfuS9xdChBazZSyvb10SZbqhYQLGBcQg==", 26155 "dev": true, 26156 "license": "BSD-3-Clause" 26157 }, 26140 26158 "node_modules/picocolors": { 26141 26159 "version": "1.1.1", -
trunk/package.json
r62150 r62157 67 67 "install-changed": "1.1.0", 68 68 "json2php": "0.0.12", 69 "php-array-reader": "2.1.3", 69 70 "postcss": "8.5.8", 70 71 "prettier": "npm:wp-prettier@3.0.3", -
trunk/tools/gutenberg/copy.js
r62081 r62157 10 10 */ 11 11 12 const child_process = require( 'child_process' );13 12 const fs = require( 'fs' ); 14 13 const path = require( 'path' ); 15 14 const json2php = require( 'json2php' ); 15 const { fromString } = require( 'php-array-reader' ); 16 16 17 17 // Paths. … … 26 26 const args = process.argv.slice( 2 ); 27 27 const buildDirArg = args.find( ( arg ) => arg.startsWith( '--build-dir=' ) ); 28 const buildTarget = buildDirArg 29 ? buildDirArg.split( '=' )[ 1 ] 30 : args.includes( '--dev' ) 31 ? 'src' 32 : 'build'; 28 const buildTarget = 'src'; 33 29 34 30 const wpIncludesDir = path.join( rootDir, buildTarget, 'wp-includes' ); … … 79 75 * value into a native JavaScript value (limited by JSON serialization). 80 76 * 81 * @throws Error when PHP source file unable to be read , or PHP is unavailable.77 * @throws Error when PHP source file unable to be read or parsed. 82 78 * 83 79 * @param {string} phpFilepath Absolute path of PHP file returning a single value. … … 85 81 */ 86 82 function readReturnedValueFromPHPFile( phpFilepath ) { 87 const results = child_process.spawnSync( 88 'php', 89 [ '-r', '$path = file_get_contents( "php://stdin" ); if ( ! is_file( $path ) ) { die( 1 ); } try { $data = require $path; } catch ( \\Throwable $e ) { die( 2 ); } $json = json_encode( $data ); if ( ! is_string( $json ) ) { die( 3 ); } echo $json;' ], 90 { 91 encoding: 'utf8', 92 input: phpFilepath, 93 } 94 ); 95 96 switch ( results.status ) { 97 case 0: 98 return JSON.parse( results.stdout ); 99 100 case 1: 101 throw new Error( `Could not read PHP source file: '${ phpFilepath }'` ); 102 103 case 2: 104 throw new Error( `PHP source file did not return value when imported: '${ phpFilepath }'` ); 105 106 case 3: 107 throw new Error( `Could not serialize PHP source value into JSON: '${ phpFilepath }'` ); 108 } 109 110 throw new Error( `Unknown error while reading PHP source file: '${ phpFilepath }'` ); 83 const content = fs.readFileSync( phpFilepath, 'utf8' ); 84 return fromString( content ); 111 85 } 112 86
Note: See TracChangeset
for help on using the changeset viewer.