|
5 | 5 | */ |
6 | 6 |
|
7 | 7 | import { execSync } from 'child_process'; |
8 | | -import { readFileSync, readdirSync } from 'fs'; |
| 8 | +import { readFileSync, readdirSync, accessSync, constants } from 'fs'; |
9 | 9 | import { join } from 'path'; |
10 | 10 |
|
11 | 11 | const packagesDir = 'packages'; |
@@ -40,17 +40,41 @@ function checkPackage(packageName) { |
40 | 40 | const actionYml = join(packagePath, 'action.yml'); |
41 | 41 | const actionYaml = join(packagePath, 'action.yaml'); |
42 | 42 |
|
| 43 | + let actionFileFound = false; |
| 44 | + let actionFileError = null; |
| 45 | + |
| 46 | + // Check for action.yml |
43 | 47 | try { |
| 48 | + accessSync(actionYml, constants.F_OK); |
44 | 49 | readFileSync(actionYml); |
45 | 50 | console.log(` ✅ Has action.yml file`); |
46 | | - } catch { |
47 | | - try { |
48 | | - readFileSync(actionYaml); |
49 | | - console.log(` ✅ Has action.yaml file`); |
50 | | - } catch { |
51 | | - console.log(` ❌ Missing action.yml/action.yaml file`); |
| 51 | + actionFileFound = true; |
| 52 | + } catch (error) { |
| 53 | + if (error.code === 'ENOENT') { |
| 54 | + // File doesn't exist, try action.yaml |
| 55 | + try { |
| 56 | + accessSync(actionYaml, constants.F_OK); |
| 57 | + readFileSync(actionYaml); |
| 58 | + console.log(` ✅ Has action.yaml file`); |
| 59 | + actionFileFound = true; |
| 60 | + } catch (yamlError) { |
| 61 | + if (yamlError.code === 'ENOENT') { |
| 62 | + console.log(` ❌ Missing action.yml/action.yaml file`); |
| 63 | + } else { |
| 64 | + console.log(` ❌ Error reading action.yaml: ${yamlError.message}`); |
| 65 | + actionFileError = yamlError; |
| 66 | + } |
| 67 | + } |
| 68 | + } else { |
| 69 | + console.log(` ❌ Error reading action.yml: ${error.message}`); |
| 70 | + actionFileError = error; |
52 | 71 | } |
53 | 72 | } |
| 73 | + |
| 74 | + // If we found an action file but had read errors, report them |
| 75 | + if (actionFileFound && actionFileError) { |
| 76 | + console.log(` ⚠️ Action file found but has read issues: ${actionFileError.message}`); |
| 77 | + } |
54 | 78 | } catch (error) { |
55 | 79 | console.log(` ❌ Error reading package.json: ${error.message}`); |
56 | 80 | } |
|
0 commit comments