Fix internal-dependency-trace script by handling commands/secrets/index.js (#10599)

This commit is contained in:
Ethan Arrowood
2023-09-27 10:52:17 -06:00
committed by GitHub
parent cb37ff2c89
commit eb06bd262b

View File

@@ -6,10 +6,17 @@ const addExtension = filePath => {
if (filePath.endsWith('.json')) {
return filePath;
}
if (!filePath.endsWith('.ts')) {
try {
fs.statSync(filePath);
fs.statSync(filePath); // its a directory, now try index.ts and index.js
try {
fs.statSync(filePath + '/index.ts');
filePath += '/index.ts';
} catch (e) {
fs.statSync(filePath + '/index.js');
filePath += '/index.js';
}
} catch (e) {
try {
fs.statSync(filePath + '.ts');
@@ -20,6 +27,7 @@ const addExtension = filePath => {
}
}
}
return filePath;
};