@@ -87,10 +87,13 @@ describe("apple", () => {
8787 } ) ;
8888
8989 describe ( "updateInfoPlist" , ( ) => {
90- it ( "updates an xml plist" , async ( context ) => {
91- const infoPlistSubPath = "Info.plist" ;
92- const tempDirectoryPath = setupTempDirectory ( context , {
93- [ infoPlistSubPath ] : `
90+ it (
91+ "updates an xml plist" ,
92+ { skip : process . platform !== "darwin" } ,
93+ async ( context ) => {
94+ const infoPlistSubPath = "Info.plist" ;
95+ const tempDirectoryPath = setupTempDirectory ( context , {
96+ [ infoPlistSubPath ] : `
9497 <?xml version="1.0" encoding="UTF-8"?>
9598 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
9699 <plist version="1.0">
@@ -100,48 +103,82 @@ describe("apple", () => {
100103 </dict>
101104 </plist>
102105 ` ,
103- } ) ;
104-
105- await updateInfoPlist ( {
106- frameworkPath : tempDirectoryPath ,
107- oldLibraryName : "addon" ,
108- newLibraryName : "new-addon-name" ,
109- } ) ;
110-
111- const contents = await fs . promises . readFile (
112- path . join ( tempDirectoryPath , infoPlistSubPath ) ,
113- "utf-8" ,
114- ) ;
115- assert . match ( contents , / < \? x m l v e r s i o n = " 1 .0 " e n c o d i n g = " U T F - 8 " \? > / ) ;
116- assert . match (
117- contents ,
118- / < k e y > C F B u n d l e E x e c u t a b l e < \/ k e y > \s * < s t r i n g > n e w - a d d o n - n a m e < \/ s t r i n g > / ,
119- ) ;
120- } ) ;
121-
122- it ( "converts a binary plist to xml" , async ( context ) => {
123- const tempDirectoryPath = setupTempDirectory ( context , { } ) ;
124- // Write a binary plist file
125- const binaryPlistContents = Buffer . from (
126- // Generated running "base64 -i <path-to-binary-plist>" on a plist file from a framework in the node-examples package
127- "YnBsaXN0MDDfEBUBAgMEBQYHCAkKCwwNDg8QERITFBUWFxgZGhscHR4cICEiIyQiJSYnJChfEBNCdWlsZE1hY2hpbmVPU0J1aWxkXxAZQ0ZCdW5kbGVEZXZlbG9wbWVudFJlZ2lvbl8QEkNGQnVuZGxlRXhlY3V0YWJsZV8QEkNGQnVuZGxlSWRlbnRpZmllcl8QHUNGQnVuZGxlSW5mb0RpY3Rpb25hcnlWZXJzaW9uXxATQ0ZCdW5kbGVQYWNrYWdlVHlwZV8QGkNGQnVuZGxlU2hvcnRWZXJzaW9uU3RyaW5nXxARQ0ZCdW5kbGVTaWduYXR1cmVfEBpDRkJ1bmRsZVN1cHBvcnRlZFBsYXRmb3Jtc18QD0NGQnVuZGxlVmVyc2lvbl8QFUNTUmVzb3VyY2VzRmlsZU1hcHBlZFpEVENvbXBpbGVyXxAPRFRQbGF0Zm9ybUJ1aWxkXkRUUGxhdGZvcm1OYW1lXxARRFRQbGF0Zm9ybVZlcnNpb25aRFRTREtCdWlsZFlEVFNES05hbWVXRFRYY29kZVxEVFhjb2RlQnVpbGRfEBBNaW5pbXVtT1NWZXJzaW9uXlVJRGV2aWNlRmFtaWx5VjI0RzIzMVdFbmdsaXNoVWFkZG9uXxAPZXhhbXBsZV82LmFkZG9uUzYuMFRGTVdLUzEuMFQ/Pz8/oR9fEA9pUGhvbmVTaW11bGF0b3IJXxAiY29tLmFwcGxlLmNvbXBpbGVycy5sbHZtLmNsYW5nLjFfMFYyMkMxNDZfEA9pcGhvbmVzaW11bGF0b3JUMTguMl8QE2lwaG9uZXNpbXVsYXRvcjE4LjJUMTYyMFgxNkM1MDMyYaEpEAEACAA1AEsAZwB8AJEAsQDHAOQA+AEVAScBPwFKAVwBawF/AYoBlAGcAakBvAHLAdIB2gHgAfIB9gH7Af8CBAIGAhgCGQI+AkUCVwJcAnICdwKAAoIAAAAAAAACAQAAAAAAAAAqAAAAAAAAAAAAAAAAAAAChA==" ,
128- "base64" ,
129- ) ;
130- const binaryPlistPath = path . join ( tempDirectoryPath , "Info.plist" ) ;
131- await fs . promises . writeFile ( binaryPlistPath , binaryPlistContents ) ;
132-
133- await updateInfoPlist ( {
134- frameworkPath : tempDirectoryPath ,
135- oldLibraryName : "addon" ,
136- newLibraryName : "new-addon-name" ,
137- } ) ;
138-
139- const contents = await fs . promises . readFile ( binaryPlistPath , "utf-8" ) ;
140- assert . match ( contents , / < \? x m l v e r s i o n = " 1 .0 " e n c o d i n g = " U T F - 8 " \? > / ) ;
141- assert . match (
142- contents ,
143- / < k e y > C F B u n d l e E x e c u t a b l e < \/ k e y > \s * < s t r i n g > n e w - a d d o n - n a m e < \/ s t r i n g > / ,
144- ) ;
145- } ) ;
106+ } ) ;
107+
108+ await updateInfoPlist ( {
109+ frameworkPath : tempDirectoryPath ,
110+ oldLibraryName : "addon" ,
111+ newLibraryName : "new-addon-name" ,
112+ } ) ;
113+
114+ const contents = await fs . promises . readFile (
115+ path . join ( tempDirectoryPath , infoPlistSubPath ) ,
116+ "utf-8" ,
117+ ) ;
118+ assert . match ( contents , / < \? x m l v e r s i o n = " 1 .0 " e n c o d i n g = " U T F - 8 " \? > / ) ;
119+ assert . match (
120+ contents ,
121+ / < k e y > C F B u n d l e E x e c u t a b l e < \/ k e y > \s * < s t r i n g > n e w - a d d o n - n a m e < \/ s t r i n g > / ,
122+ ) ;
123+ } ,
124+ ) ;
125+
126+ it (
127+ "converts a binary plist to xml" ,
128+ { skip : process . platform !== "darwin" } ,
129+ async ( context ) => {
130+ const tempDirectoryPath = setupTempDirectory ( context , { } ) ;
131+ // Write a binary plist file
132+ const binaryPlistContents = Buffer . from (
133+ // Generated running "base64 -i <path-to-binary-plist>" on a plist file from a framework in the node-examples package
134+ "YnBsaXN0MDDfEBUBAgMEBQYHCAkKCwwNDg8QERITFBUWFxgZGhscHR4cICEiIyQiJSYnJChfEBNCdWlsZE1hY2hpbmVPU0J1aWxkXxAZQ0ZCdW5kbGVEZXZlbG9wbWVudFJlZ2lvbl8QEkNGQnVuZGxlRXhlY3V0YWJsZV8QEkNGQnVuZGxlSWRlbnRpZmllcl8QHUNGQnVuZGxlSW5mb0RpY3Rpb25hcnlWZXJzaW9uXxATQ0ZCdW5kbGVQYWNrYWdlVHlwZV8QGkNGQnVuZGxlU2hvcnRWZXJzaW9uU3RyaW5nXxARQ0ZCdW5kbGVTaWduYXR1cmVfEBpDRkJ1bmRsZVN1cHBvcnRlZFBsYXRmb3Jtc18QD0NGQnVuZGxlVmVyc2lvbl8QFUNTUmVzb3VyY2VzRmlsZU1hcHBlZFpEVENvbXBpbGVyXxAPRFRQbGF0Zm9ybUJ1aWxkXkRUUGxhdGZvcm1OYW1lXxARRFRQbGF0Zm9ybVZlcnNpb25aRFRTREtCdWlsZFlEVFNES05hbWVXRFRYY29kZVxEVFhjb2RlQnVpbGRfEBBNaW5pbXVtT1NWZXJzaW9uXlVJRGV2aWNlRmFtaWx5VjI0RzIzMVdFbmdsaXNoVWFkZG9uXxAPZXhhbXBsZV82LmFkZG9uUzYuMFRGTVdLUzEuMFQ/Pz8/oR9fEA9pUGhvbmVTaW11bGF0b3IJXxAiY29tLmFwcGxlLmNvbXBpbGVycy5sbHZtLmNsYW5nLjFfMFYyMkMxNDZfEA9pcGhvbmVzaW11bGF0b3JUMTguMl8QE2lwaG9uZXNpbXVsYXRvcjE4LjJUMTYyMFgxNkM1MDMyYaEpEAEACAA1AEsAZwB8AJEAsQDHAOQA+AEVAScBPwFKAVwBawF/AYoBlAGcAakBvAHLAdIB2gHgAfIB9gH7Af8CBAIGAhgCGQI+AkUCVwJcAnICdwKAAoIAAAAAAAACAQAAAAAAAAAqAAAAAAAAAAAAAAAAAAAChA==" ,
135+ "base64" ,
136+ ) ;
137+ const binaryPlistPath = path . join ( tempDirectoryPath , "Info.plist" ) ;
138+ await fs . promises . writeFile ( binaryPlistPath , binaryPlistContents ) ;
139+
140+ await updateInfoPlist ( {
141+ frameworkPath : tempDirectoryPath ,
142+ oldLibraryName : "addon" ,
143+ newLibraryName : "new-addon-name" ,
144+ } ) ;
145+
146+ const contents = await fs . promises . readFile ( binaryPlistPath , "utf-8" ) ;
147+ assert . match ( contents , / < \? x m l v e r s i o n = " 1 .0 " e n c o d i n g = " U T F - 8 " \? > / ) ;
148+ assert . match (
149+ contents ,
150+ / < k e y > C F B u n d l e E x e c u t a b l e < \/ k e y > \s * < s t r i n g > n e w - a d d o n - n a m e < \/ s t r i n g > / ,
151+ ) ;
152+ } ,
153+ ) ;
154+
155+ it (
156+ "throws when not on darwin" ,
157+ { skip : process . platform === "darwin" } ,
158+ async ( context ) => {
159+ const tempDirectoryPath = setupTempDirectory ( context , {
160+ [ "Info.plist" ] : '<?xml version="1.0" encoding="UTF-8"?>' ,
161+ } ) ;
162+
163+ await assert . rejects (
164+ ( ) =>
165+ updateInfoPlist ( {
166+ frameworkPath : tempDirectoryPath ,
167+ oldLibraryName : "addon" ,
168+ newLibraryName : "new-addon-name" ,
169+ } ) ,
170+ ( err ) => {
171+ assert ( err instanceof Error ) ;
172+ assert . match ( err . message , / F a i l e d t o c o n v e r t I n f o .p l i s t a t p a t h / ) ;
173+ assert ( err . cause instanceof Error ) ;
174+ assert . match (
175+ err . cause . message ,
176+ / U p d a t i n g I n f o .p l i s t f i l e s a r e n o t s u p p o r t e d o n t h i s p l a t f o r m / ,
177+ ) ;
178+ return true ;
179+ } ,
180+ ) ;
181+ } ,
182+ ) ;
146183 } ) ;
147184} ) ;
0 commit comments