Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(generateSearch): move config missing error to require #13160

Merged
merged 2 commits into from
Mar 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions scripts/generateSearch.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
'use strict';

const config = require('../.config');
let config;
try {
config = require('../.config.js');
} finally {
if (!config || !config.uri) {
console.error('No Config or config.URI given, please create a .config.js file with those values in the root of the repository');
process.exit(-1);
}
}
const cheerio = require('cheerio');
const filemap = require('../docs/source');
const fs = require('fs');
Expand Down Expand Up @@ -120,11 +128,6 @@ run().catch(async error => {
});

async function run() {
if (!config || !config.uri) {
console.error('No Config or config.URI given, please create a .config.js file with those values');
process.exit(-1);
}

await mongoose.connect(config.uri, { dbName: 'mongoose', serverSelectionTimeoutMS: 5000 });

// wait for the index to be created
Expand Down Expand Up @@ -152,5 +155,7 @@ async function run() {

console.log(results.map(res => res.url));

console.log(`Added ${contents.length} Content`);

process.exit(0);
}