diff --git a/common/app/routes/challenges/redux/reducer.js b/common/app/routes/challenges/redux/reducer.js index cd73838df1..eeb0ec8532 100644 --- a/common/app/routes/challenges/redux/reducer.js +++ b/common/app/routes/challenges/redux/reducer.js @@ -3,7 +3,7 @@ import { createPoly } from '../../../../utils/polyvinyl'; import types from './types'; import { BONFIRE, HTML, JS } from '../../../utils/challengeTypes'; -import { buildSeed, createTests, getPath } from '../utils'; +import { arrayToString, buildSeed, createTests, getPath } from '../utils'; const initialState = { challenge: '', @@ -82,7 +82,9 @@ const filesReducer = handleActions( ...state, [path]: createPoly({ path, - contents: buildSeed(challenge) + contents: buildSeed(challenge), + head: arrayToString(challenge.head), + tail: arrayToString(challenge.tail) }) }; } diff --git a/common/app/routes/challenges/utils.js b/common/app/routes/challenges/utils.js index bde8590743..73010f01d6 100644 --- a/common/app/routes/challenges/utils.js +++ b/common/app/routes/challenges/utils.js @@ -27,7 +27,7 @@ export function decodeFccfaaAttr(value) { ); } -export function arrayToNewLineString(seedData = []) { +export function arrayToString(seedData = ['']) { seedData = Array.isArray(seedData) ? seedData : [seedData]; return seedData.reduce((seed, line) => '' + seed + line + '\n', '\n'); } @@ -35,7 +35,7 @@ export function arrayToNewLineString(seedData = []) { export function buildSeed({ challengeSeed = [] } = {}) { return compose( decodeSafeTags, - arrayToNewLineString + arrayToString )(challengeSeed); } diff --git a/common/utils/polyvinyl.js b/common/utils/polyvinyl.js index 234a9a2450..77ee95f70e 100644 --- a/common/utils/polyvinyl.js +++ b/common/utils/polyvinyl.js @@ -15,7 +15,7 @@ import invariant from 'invariant'; // contents: String, // history?: [...String], // }) => PolyVinyl, throws -export function createPoly({ path, contents, history } = {}) { +export function createPoly({ path, contents, history, ...rest } = {}) { invariant( typeof path === 'string', 'path must be a string but got %s', @@ -29,6 +29,7 @@ export function createPoly({ path, contents, history } = {}) { ); return { + ...rest, history: Array.isArray(history) ? history : [ path ], path: path, contents: contents,