feat: Use prettier-eslint to format code
This commit is contained in:
committed by
mrugesh mohapatra
parent
1ba67c4e2b
commit
b13e5fb41a
@ -26,66 +26,61 @@ function handleError(err, client) {
|
||||
}
|
||||
}
|
||||
|
||||
MongoClient.connect(
|
||||
MONGOHQ_URL,
|
||||
{ useNewUrlParser: true },
|
||||
function(err, client) {
|
||||
MongoClient.connect(MONGOHQ_URL, { useNewUrlParser: true }, function(
|
||||
err,
|
||||
client
|
||||
) {
|
||||
handleError(err, client);
|
||||
|
||||
log('Connected successfully to mongo at %s', MONGOHQ_URL);
|
||||
|
||||
const db = client.db('freecodecamp');
|
||||
const challengeCollection = db.collection('challenge');
|
||||
|
||||
challengeCollection.deleteMany({}, async err => {
|
||||
handleError(err, client);
|
||||
|
||||
log('Connected successfully to mongo at %s', MONGOHQ_URL);
|
||||
log('deleted all the challenges');
|
||||
|
||||
const db = client.db('freecodecamp');
|
||||
const challengeCollection = db.collection('challenge');
|
||||
const curriculum = await getChallengesForLang(lang);
|
||||
|
||||
challengeCollection.deleteMany({}, async err => {
|
||||
handleError(err, client);
|
||||
|
||||
log('deleted all the challenges');
|
||||
|
||||
const curriculum = await getChallengesForLang(lang);
|
||||
|
||||
const allChallenges = Object.keys(curriculum)
|
||||
.map(key => curriculum[key].blocks)
|
||||
.reduce((challengeArray, superBlock) => {
|
||||
const challengesForBlock = Object.keys(superBlock).map(
|
||||
key => superBlock[key].challenges
|
||||
);
|
||||
return [...challengeArray, ...flatten(challengesForBlock)];
|
||||
}, [])
|
||||
.map(challenge => {
|
||||
const currentId = challenge.id.slice(0);
|
||||
challenge._id = ObjectID(currentId);
|
||||
delete challenge.id;
|
||||
return challenge;
|
||||
});
|
||||
|
||||
try {
|
||||
challengeCollection.insertMany(
|
||||
allChallenges,
|
||||
{ ordered: false },
|
||||
err => {
|
||||
handleError(err, client);
|
||||
log('challenge seed complete');
|
||||
client.close();
|
||||
}
|
||||
const allChallenges = Object.keys(curriculum)
|
||||
.map(key => curriculum[key].blocks)
|
||||
.reduce((challengeArray, superBlock) => {
|
||||
const challengesForBlock = Object.keys(superBlock).map(
|
||||
key => superBlock[key].challenges
|
||||
);
|
||||
} catch (e) {
|
||||
handleError(e, client);
|
||||
} finally {
|
||||
log('generating path migration map');
|
||||
const pathMap = createPathMigrationMap(curriculum);
|
||||
const outputDir = path.resolve(
|
||||
__dirname,
|
||||
'../../../api-server/server/resources/pathMigration.json'
|
||||
);
|
||||
fs.writeFile(outputDir, JSON.stringify(pathMap), err => {
|
||||
if (err) {
|
||||
console.error('Oh noes!!');
|
||||
console.error(err);
|
||||
}
|
||||
log('path migration map generated');
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
return [...challengeArray, ...flatten(challengesForBlock)];
|
||||
}, [])
|
||||
.map(challenge => {
|
||||
const currentId = challenge.id.slice(0);
|
||||
challenge._id = ObjectID(currentId);
|
||||
delete challenge.id;
|
||||
return challenge;
|
||||
});
|
||||
|
||||
try {
|
||||
challengeCollection.insertMany(allChallenges, { ordered: false }, err => {
|
||||
handleError(err, client);
|
||||
log('challenge seed complete');
|
||||
client.close();
|
||||
});
|
||||
} catch (e) {
|
||||
handleError(e, client);
|
||||
} finally {
|
||||
log('generating path migration map');
|
||||
const pathMap = createPathMigrationMap(curriculum);
|
||||
const outputDir = path.resolve(
|
||||
__dirname,
|
||||
'../../../api-server/server/resources/pathMigration.json'
|
||||
);
|
||||
fs.writeFile(outputDir, JSON.stringify(pathMap), err => {
|
||||
if (err) {
|
||||
console.error('Oh noes!!');
|
||||
console.error(err);
|
||||
}
|
||||
log('path migration map generated');
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user