@@ -366,12 +366,20 @@ function ScriptOperator(script, targetPlatform, $arguments, source, $options) {
366366 if ( output ?. $file ?. type === 'mihomoProfile' ) {
367367 try {
368368 let patch = YAML . safeLoad ( script ) ;
369+ let config ;
370+ if ( output ?. $content ) {
371+ try {
372+ config = YAML . safeLoad ( output ?. $content ) ;
373+ } catch ( e ) {
374+ $ . error ( e . message ?? e ) ;
375+ }
376+ }
369377 // if (typeof patch !== 'object') patch = {};
370378 if ( typeof patch !== 'object' )
371379 throw new Error ( 'patch is not an object' ) ;
372380 output . $content = ProxyUtils . yaml . safeDump (
373381 deepMerge (
374- {
382+ config || {
375383 proxies : await produceArtifact ( {
376384 type :
377385 output ?. $file ?. sourceType ||
@@ -414,7 +422,15 @@ function ScriptOperator(script, targetPlatform, $arguments, source, $options) {
414422 if($file.type === 'mihomoProfile') {
415423 ${ script }
416424 if(typeof main === 'function') {
417- const config = {
425+ let config;
426+ if ($content) {
427+ try {
428+ config = ProxyUtils.yaml.safeLoad($content);
429+ } catch (e) {
430+ console.log(e.message ?? e);
431+ }
432+ }
433+ $content = ProxyUtils.yaml.safeDump(await main(config || {
418434 proxies: await produceArtifact({
419435 type: $file.sourceType || 'collection',
420436 name: $file.sourceName,
@@ -424,8 +440,7 @@ function ScriptOperator(script, targetPlatform, $arguments, source, $options) {
424440 'delete-underscore-fields': true
425441 }
426442 }),
427- }
428- $content = ProxyUtils.yaml.safeDump(await main(config))
443+ }))
429444 }
430445 } else {
431446 ${ script }
0 commit comments