Correctly generate with or without index.

This commit is contained in:
Dillon Kearns 2019-09-15 13:29:43 -07:00
parent 9a2f1c3753
commit 2b06f0dc9f
2 changed files with 6 additions and 5 deletions

View File

@ -102,7 +102,7 @@ images =
{ dillon = (buildImage [ "dillon.jpg" ])
, icon = (buildImage [ "icon.svg" ])
, mountains = (buildImage [ "mountains.jpg" ])
, directory = directoryWithIndex []
, directory = directoryWithoutIndex []
}
allImages : List (ImagePath PathKey)

View File

@ -162,7 +162,8 @@ function formatRecord(directoryPath, rec, asType, level) {
var keyVals = [];
const indentation = " ".repeat(level * 4);
var valsAtThisLevel = [];
for (const key of Object.keys(rec)) {
const keys = Object.keys(rec);
for (const key of keys) {
var val = rec[key];
if (typeof val === "string") {
@ -182,9 +183,9 @@ function formatRecord(directoryPath, rec, asType, level) {
}
}
keyVals.push(
`directory = directoryWithIndex [${directoryPath
.map(pathFragment => `"${pathFragment}"`)
.join(", ")}]`
`directory = ${
keys.includes("index") ? "directoryWithIndex" : "directoryWithoutIndex"
} [${directoryPath.map(pathFragment => `"${pathFragment}"`).join(", ")}]`
);
const indentationDelimiter = `\n${indentation}, `;
return `${indentation}{ ${keyVals.join(indentationDelimiter)}