import { promises as fs } from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { test, exec } from 'uvu';
import * as assert from 'uvu/assert';

(async () => {
  const __dirname = path.dirname(fileURLToPath(import.meta.url)),
    root = path.dirname(__dirname),
    darkIconsPath = path.join(root, 'icons'),
    lightIconsPath = path.join(root, 'assets', 'readme'),
    lightIconsFileNames = await fs.readdir(lightIconsPath);

  for (let lightIconFileName of lightIconsFileNames) {
    const lightIconPath = path.join(lightIconsPath, lightIconFileName),
      darkIconPath = path.join(
        darkIconsPath,
        lightIconFileName.replace(/-white\.svg$/, '.svg'),
      ),
      lightIconRelPath = path.relative(root, lightIconPath),
      darkIconRelPath = path.relative(root, darkIconPath),
      lightIconContent = await fs.readFile(lightIconPath, 'utf8'),
      darkIconContent = await fs.readFile(darkIconPath, 'utf8');

    test(`'${lightIconRelPath}' content must be equivalent to '${darkIconRelPath}' content`, () => {
      assert.equal(
        lightIconContent.replace(' fill="white"', ''),
        darkIconContent,
      );
    });
  }
  test.run();
  exec();
})();

@@ -4,26 +4,10 @@
 ort 
-%7B promises as fs %7D
+fs
  fro
@@ -108,14 +108,8 @@
 test
-, exec
  %7D f
@@ -162,25 +162,8 @@
 ';%0A%0A
-(async () =%3E %7B%0A  
 cons
@@ -220,21 +220,23 @@
 ta.url))
-,%0A   
+;%0Aconst
  root = 
@@ -262,17 +262,20 @@
 ame)
-,%0A    dar
+;%0Aconst blac
 kIco
@@ -307,27 +307,29 @@
 'icons')
-,%0A    light
+;%0Aconst white
 IconsPat
@@ -371,19 +371,21 @@
 me')
-,%0A    light
+;%0Aconst white
 Icon
@@ -396,22 +396,16 @@
 eNames =
- await
  fs.read
@@ -407,22 +407,26 @@
 .readdir
-(light
+Sync(white
 IconsPat
@@ -430,18 +430,16 @@
 Path);%0A%0A
-  
 for (let
@@ -439,21 +439,21 @@
 or (let 
-light
+white
 IconFile
@@ -460,21 +460,21 @@
 Name of 
-light
+white
 IconsFil
@@ -487,18 +487,16 @@
 ) %7B%0A
-  
   const 
 ligh
@@ -491,21 +491,21 @@
   const 
-light
+white
 IconPath
@@ -517,21 +517,21 @@
 th.join(
-light
+white
 IconsPat
@@ -533,21 +533,21 @@
 nsPath, 
-light
+white
 IconFile
@@ -551,27 +551,30 @@
 ileName)
-,%0A      dar
+;%0A  const blac
 kIconPat
@@ -588,31 +588,28 @@
 h.join(%0A    
-    dar
+blac
 kIconsPath,%0A
@@ -608,33 +608,29 @@
 nsPath,%0A    
-    light
+white
 IconFileName
@@ -669,26 +669,24 @@
 ,%0A  
-    ),%0A      light
+);%0A  const white
 Icon
@@ -715,21 +715,21 @@
 e(root, 
-light
+white
 IconPath
@@ -729,27 +729,30 @@
 conPath)
-,%0A      dar
+;%0A  const blac
 kIconRel
@@ -778,19 +778,20 @@
 e(root, 
-dar
+blac
 kIconPat
@@ -796,211 +796,469 @@
 ath)
-,%0A      lightIconContent = await fs.readFile(light
+;%0A%0A  test(%60'$%7BwhiteIconRelPath%7D' content must be equivalent to '$%7Bblack
 Icon
+Rel
 Path
-, 'utf8'),%0A      darkIconContent = await fs.readFile(darkIconPa
+%7D' content%60, () =%3E %7B%0A    assert.ok(%0A      whiteIconFileName.endsWith('-white.svg'),%0A      %60README icon assets file name '$%7BwhiteIconFileName%7D'%60 +%0A        %22 must ends wi
 th
-,
  '
-utf8');%0A%0A    test(%60'$%7BlightIconRelPath%7D' content must be equivalent to '$%7Bdar
+-white.svg'.%22,%0A    );%0A%0A    assert.ok(%0A      fs.existsSync(blackIconPath),%0A      %60Corresponding icon '$%7BblackIconRelPath%7D' for README asset '$%7BwhiteIconRelPath%7D'%60 +%0A        %60 not found in '$%7Bpath.dirname(blac
 kIco
@@ -1269,35 +1269,175 @@
 Path
+)
 %7D' 
-content%60, () =%3E %7B
+directory.%60,%0A    );%0A%0A    const whiteIconContent = fs.readFileSync(whiteIconPath, 'utf8');%0A    const blackIconContent = fs.readFileSync(blackIconPath, 'utf8');
 %0A    
-  
 asse
@@ -1456,15 +1456,37 @@
     
-  light
+whiteIconContent,%0A      black
 Icon
@@ -1502,16 +1502,28 @@
 eplace('
+%3Csvg', '%3Csvg
  fill=%22w
@@ -1532,42 +1532,11 @@
 te%22'
-, ''
 ),%0A
-        darkIconContent,%0A  
     
@@ -1544,17 +1544,12 @@
 ;%0A  
-  
 %7D);%0A
-  %7D
 %0A  t
@@ -1563,20 +1563,6 @@
 ();%0A
-  exec();%0A%7D)();
+%7D
 %0A

Fix some cases in README icons tests (#7056)