Skip to content

Commit 5620cb7

Browse files
committed
chore: standardize utils.js wrapper across all consumer repos
1 parent 6dca8d1 commit 5620cb7

File tree

1 file changed

+6
-20
lines changed

1 file changed

+6
-20
lines changed

.github/scripts/job-fetcher/utils.js

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,33 +27,19 @@ const path = require('path');
2727
// Import shared utilities library
2828
const sharedUtils = require('../shared/lib/utils');
2929

30-
// Try to load company database (different filenames for different repos)
31-
// Main repos: companies.json
32-
// SEO repos: software.json, data-science.json, hardware.json, etc.
30+
// Load company database if present (New-Grad and Internships repos have companies.json;
31+
// SEO repos do not — company emoji/career URL features degrade gracefully to defaults)
3332
let companies = {};
34-
const possibleFiles = ['companies.json', 'software.json', 'data-science.json', 'hardware.json', 'nursing.json'];
3533

36-
for (const file of possibleFiles) {
37-
const filePath = path.join(__dirname, file);
38-
if (fs.existsSync(filePath)) {
39-
companies = JSON.parse(fs.readFileSync(filePath, 'utf8'));
40-
break;
41-
}
42-
}
34+
const companiesPath = path.join(__dirname, 'companies.json');
35+
if (fs.existsSync(companiesPath)) {
36+
companies = JSON.parse(fs.readFileSync(companiesPath, 'utf8'));
4337

44-
// Initialize shared library with this repo's company data (if found and compatible format)
45-
// Main repos use format: {category: [{name, api_names}, ...]}
46-
// SEO repos use format: {category: {title, companies: [names]}}
47-
// Only initialize for Main repo format to avoid errors
48-
if (Object.keys(companies).length > 0) {
38+
// Only initialize for the expected format: {category: [{name, api_names}, ...]}
4939
const firstCategory = Object.values(companies)[0];
50-
51-
// Check if Main repo format (array of company objects)
5240
if (Array.isArray(firstCategory)) {
5341
sharedUtils.initCompanyDatabase(companies);
5442
}
55-
// SEO repo format - skip company init, just use shared filtering logic
56-
// Company-specific features won't work, but core filtering (US location, experience level) will
5743
}
5844

5945
// Re-export all shared utilities

0 commit comments

Comments
 (0)