import _ from 'lodash';
import path from 'path';
import { Observable } from 'rx';

const basePath = process.cwd() + '/seed/challenges/';

export default function getFromDisk$(challenge) {
  delete require.cache[require.resolve(
    path.join(basePath, challenge.fileName)
  )];

  return Observable.just(require(path.join(basePath, challenge.fileName)))
    .map(challengeSpec => challengeSpec.challenges[challenge.suborder - 1])
    .map(challenge => {
      challenge.head = challenge.head || [];
      challenge.tail = challenge.tail || [];
      challenge.challengeType = '' + challenge.challengeType;

      challenge.name =
        _.capitalize(challenge.type) +
        ': ' +
        challenge.title.replace(/[^a-zA-Z0-9\s]/g, '');

      challenge.dashedName = challenge.name
        .toLowerCase()
        .replace(/\:/g, '')
        .replace(/\s/g, '-');

      return challenge;
    });
}

@@ -181,16 +181,181 @@
 enge) %7B%0A
+  if (challenge && !challenge.fileName) %7B%0A    throw new Error(%0A      %60Challenge $%7Bchallenge.name%7D has no fileName.%0A      Did you remember run node seed?%60%0A    );%0A  %7D%0A
   delete

Add helpful error message if no filename