@@ -27,6 +27,9 @@ export const parseLibraryReference =
2727 latestRelease = 'v' + latestRelease ;
2828 }
2929
30+ const useExternalP5Sound = ! ! process . env . P5_REPO_BRANCH ||
31+ latestRelease . startsWith ( 'v2' ) ;
32+
3033 // Clone p5.js
3134 await cloneLibraryRepo (
3235 localPath ,
@@ -36,56 +39,68 @@ export const parseLibraryReference =
3639 ) ;
3740
3841 // Install dependencies and build docs in the p5 repo
39- await createP5Docs ( 'p5.js' , 'data-p5' )
42+ await createP5Docs ( 'p5.js' , 'data-p5' ) ;
4043
4144 // If we're using a custom build of p5 instead of a public release, create
4245 // a build and copy it to the specified path
4346 if ( process . env . PUBLIC_P5_LIBRARY_PATH ) {
44- await createP5Build ( 'p5.js' , '../../../public' + process . env . PUBLIC_P5_LIBRARY_PATH )
47+ await createP5Build ( 'p5.js' , '../../../public' + process . env . PUBLIC_P5_LIBRARY_PATH ) ;
4548 }
4649
4750 // Copy the reference output so we can process it
4851 const p5Data = await getYuidocOutput ( 'data-p5' ) ;
4952 if ( ! p5Data ) throw new Error ( 'Error generating p5 reference data!' ) ;
5053
51- // Clone p5.sound.js
52- await cloneLibraryRepo (
53- localSoundPath ,
54- 'https://github.com/processing/p5.sound.js.git' ,
55- 'main'
56- ) ;
57- await saveYuidocOutput ( 'p5.sound.js' , 'data-sound' ) ;
58- const soundData = await getYuidocOutput ( 'data-sound' ) ;
59- if ( ! soundData ) throw new Error ( 'Error generating p5.sound reference data!' ) ;
60-
61- // Fix p5.sound classes
62- for ( const key in soundData . classes ) {
63- const newName = 'p5.' + soundData . classes [ key ] . name ;
64- const updated = {
65- ...soundData . classes [ key ] ,
66- name : newName ,
67- } ;
68- soundData . classes [ newName ] = updated ;
69- delete soundData . classes [ key ] ;
70- }
71- for ( const item of soundData . classitems ) {
72- item . class = 'p5.' + item . class ;
73- }
54+ let result ;
55+ if ( useExternalP5Sound ) {
56+ console . log ( 'Cloning separate p5.sound repo' ) ;
57+
58+ // Clone p5.sound.js
59+ await cloneLibraryRepo (
60+ localSoundPath ,
61+ 'https://github.com/processing/p5.sound.js.git' ,
62+ 'main'
63+ ) ;
64+ await saveYuidocOutput ( 'p5.sound.js' , 'data-sound' ) ;
65+ const soundData = await getYuidocOutput ( 'data-sound' ) ;
66+ if ( ! soundData ) throw new Error ( 'Error generating p5.sound reference data!' ) ;
67+
68+ // Fix p5.sound classes
69+ for ( const key in soundData . classes ) {
70+ const newName = 'p5.' + soundData . classes [ key ] . name ;
71+ const updated = {
72+ ...soundData . classes [ key ] ,
73+ name : newName ,
74+ } ;
75+ soundData . classes [ newName ] = updated ;
76+ delete soundData . classes [ key ] ;
77+ }
78+ for ( const item of soundData . classitems ) {
79+ item . class = 'p5.' + item . class ;
80+ }
7481
75- const combined = await combineYuidocData (
76- [
77- p5Data ,
78- soundData ,
79- ] ,
80- 'data'
81- ) ;
82+ result = await combineYuidocData (
83+ [
84+ p5Data ,
85+ soundData ,
86+ ] ,
87+ 'data'
88+ ) ;
89+ } else {
90+ result = await combineYuidocData (
91+ [
92+ p5Data ,
93+ ] ,
94+ 'data'
95+ ) ;
96+ }
8297
8398 await serveYuidocOutput ( 'data' ) ;
8499
85100 //delete the cloned directories
86101 await cleanUpDirectory ( parsersInPath ) ;
87102 await cleanUpDirectory ( parsersOutPath ) ;
88- return combined ;
103+ return result ;
89104 } ;
90105
91106/**
0 commit comments