Add head/tail to file
This commit is contained in:
@ -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)
|
||||
})
|
||||
};
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
Reference in New Issue
Block a user