use correct name, fixes #77
This commit is contained in:
@@ -41,12 +41,6 @@ const checkAttributes = (fileName, attributes) => {
|
|||||||
if (attributes.quadrant && !config_1.quadrants.includes(attributes.quadrant)) {
|
if (attributes.quadrant && !config_1.quadrants.includes(attributes.quadrant)) {
|
||||||
throw new Error(`Error: ${fileName} has an illegal value for 'quadrant' - must be one of ${config_1.quadrants}`);
|
throw new Error(`Error: ${fileName} has an illegal value for 'quadrant' - must be one of ${config_1.quadrants}`);
|
||||||
}
|
}
|
||||||
if (!attributes.quadrant || attributes.quadrant === '') {
|
|
||||||
// throw new Error(`Error: ${fileName} has no 'quadrant' set`);
|
|
||||||
}
|
|
||||||
if (!attributes.title || attributes.title === '') {
|
|
||||||
attributes.title = path_1.default.basename(fileName);
|
|
||||||
}
|
|
||||||
return attributes;
|
return attributes;
|
||||||
};
|
};
|
||||||
const createRevisionsFromFiles = (fileNames) => Promise.all(fileNames.map(fileName => {
|
const createRevisionsFromFiles = (fileNames) => Promise.all(fileNames.map(fileName => {
|
||||||
@@ -67,9 +61,9 @@ const createRevisionsFromFiles = (fileNames) => Promise.all(fileNames.map(fileNa
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
const itemInfoFromFilename = (fileName) => {
|
const itemInfoFromFilename = (fileName) => {
|
||||||
const [release, nameWithSuffix] = fileName.split(path_1.default.sep).slice(-2);
|
const [release, name] = fileName.split(path_1.default.sep).slice(-2);
|
||||||
return {
|
return {
|
||||||
name: nameWithSuffix.substr(0, nameWithSuffix.length - 3),
|
name: path_1.default.basename(name, '.md'),
|
||||||
release,
|
release,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -85,7 +79,7 @@ const createItems = (revisions) => {
|
|||||||
const itemMap = revisions.reduce((items, revision) => {
|
const itemMap = revisions.reduce((items, revision) => {
|
||||||
return Object.assign(Object.assign({}, items), { [revision.name]: addRevisionToItem(items[revision.name], revision) });
|
return Object.assign(Object.assign({}, items), { [revision.name]: addRevisionToItem(items[revision.name], revision) });
|
||||||
}, {});
|
}, {});
|
||||||
return Object.values(itemMap).sort((x, y) => (x.name > y.name ? 1 : -1));
|
return Object.values(itemMap).map(item => (Object.assign(Object.assign({}, item), { ['title']: item.title || item.name }))).sort((x, y) => (x.name > y.name ? 1 : -1));
|
||||||
};
|
};
|
||||||
const ignoreEmptyRevisionBody = (revision, item) => {
|
const ignoreEmptyRevisionBody = (revision, item) => {
|
||||||
if (!revision.body || revision.body.trim() === '') {
|
if (!revision.body || revision.body.trim() === '') {
|
||||||
|
|||||||
@@ -35,14 +35,6 @@ const checkAttributes = (fileName: string, attributes: FMAttributes) => {
|
|||||||
throw new Error(`Error: ${fileName} has an illegal value for 'quadrant' - must be one of ${quadrants}`);
|
throw new Error(`Error: ${fileName} has an illegal value for 'quadrant' - must be one of ${quadrants}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!attributes.quadrant || attributes.quadrant === '') {
|
|
||||||
// throw new Error(`Error: ${fileName} has no 'quadrant' set`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!attributes.title || attributes.title === '') {
|
|
||||||
attributes.title = path.basename(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
return attributes
|
return attributes
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -76,9 +68,9 @@ const createRevisionsFromFiles = (fileNames: string[]) =>
|
|||||||
);
|
);
|
||||||
|
|
||||||
const itemInfoFromFilename = (fileName: string) => {
|
const itemInfoFromFilename = (fileName: string) => {
|
||||||
const [release, nameWithSuffix] = fileName.split(path.sep).slice(-2);
|
const [release, name] = fileName.split(path.sep).slice(-2);
|
||||||
return {
|
return {
|
||||||
name: nameWithSuffix.substr(0, nameWithSuffix.length - 3),
|
name: path.basename(name, '.md'),
|
||||||
release,
|
release,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -101,7 +93,7 @@ const createItems = (revisions: Revision[]) => {
|
|||||||
};
|
};
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
return Object.values(itemMap).sort((x, y) => (x.name > y.name ? 1 : -1));
|
return Object.values(itemMap).map(item => ({...item, ['title']: item.title || item.name})).sort((x, y) => (x.name > y.name ? 1 : -1));
|
||||||
};
|
};
|
||||||
|
|
||||||
const ignoreEmptyRevisionBody = (revision: Revision, item: Item) => {
|
const ignoreEmptyRevisionBody = (revision: Revision, item: Item) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user