Feature in dev mode always pull from disk
This commit is contained in:
@@ -4,7 +4,15 @@ import moment from 'moment';
|
||||
import { Observable, Scheduler } from 'rx';
|
||||
import assign from 'object.assign';
|
||||
import debugFactory from 'debug';
|
||||
import utils from '../utils';
|
||||
|
||||
import {
|
||||
dasherize,
|
||||
unDasherize,
|
||||
getMDNLinks,
|
||||
randomVerb,
|
||||
randomPhrase,
|
||||
randomCompliment
|
||||
} from '../utils';
|
||||
|
||||
import {
|
||||
saveUser,
|
||||
@@ -16,6 +24,8 @@ import {
|
||||
ifNoUserSend
|
||||
} from '../utils/middleware';
|
||||
|
||||
import getFromDisk$ from '../utils/getFromDisk$';
|
||||
|
||||
const isDev = process.env.NODE_ENV !== 'production';
|
||||
const isBeta = !!process.env.BETA;
|
||||
const debug = debugFactory('freecc:challenges');
|
||||
@@ -31,10 +41,6 @@ const challengeView = {
|
||||
7: 'coursewares/showStep'
|
||||
};
|
||||
|
||||
const dasherize = utils.dasherize;
|
||||
const unDasherize = utils.unDasherize;
|
||||
const getMDNLinks = utils.getMDNLinks;
|
||||
|
||||
/*
|
||||
function makeChallengesUnique(challengeArr) {
|
||||
// clone and reverse challenges
|
||||
@@ -262,6 +268,12 @@ module.exports = function(app) {
|
||||
return testChallengeName.test(challenge.name);
|
||||
})
|
||||
.last({ defaultValue: null })
|
||||
.flatMap(challenge => {
|
||||
if (challenge && isDev) {
|
||||
return getFromDisk$(challenge);
|
||||
}
|
||||
return Observable.just(challenge);
|
||||
})
|
||||
.flatMap(challenge => {
|
||||
|
||||
// Handle not found
|
||||
@@ -311,11 +323,9 @@ module.exports = function(app) {
|
||||
MDNlinks: getMDNLinks(challenge.MDNlinks),
|
||||
|
||||
// htmls specific
|
||||
environment: utils.whichEnvironment(),
|
||||
|
||||
verb: utils.randomVerb(),
|
||||
phrase: utils.randomPhrase(),
|
||||
compliment: utils.randomCompliment()
|
||||
verb: randomVerb(),
|
||||
phrase: randomPhrase(),
|
||||
compliment: randomCompliment()
|
||||
});
|
||||
})
|
||||
.subscribe(
|
||||
|
Reference in New Issue
Block a user