Skip to content

Commit

Permalink
improve meca output msg
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonstyle committed Jul 21, 2023
1 parent bf81a03 commit 0a2de51
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/project/types/manuscript/manuscript-meca.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import * as ld from "../../../core/lodash.ts";
import { projectType } from "../project-types.ts";
import { engineIgnoreDirs } from "../../../execute/engine.ts";
import { lsFiles } from "../../../core/git.ts";
import { info } from "log/mod.ts";

const kArticleMetadata = "article-metadata";
const kArticleSupportingFile = "article-supporting-file";
Expand Down Expand Up @@ -278,6 +279,23 @@ export const createMecaBundle = async (
manuscriptZipFiles.push(workingPath);
});
}

const msg = (count: number, nameSing: string, namePlur: string) => {
if (count === 1) {
info(` ${count} ${nameSing}`);
} else if (count > 1) {
info(` ${count} ${namePlur}`);
}
};

// +1 for the manuscript file itself
msg(
1 + manuscriptResources.length + articleRenderingPaths.length,
"article file",
"article files",
);
msg(Object.keys(srcFiles).length, "source file", "source files");

// Copy resources
const resources = [];
resources.push(...jatsArticle.resources);
Expand All @@ -290,6 +308,7 @@ export const createMecaBundle = async (
notebooks.forEach((notebook) => {
resources.push(notebook.notebook);
});
msg(notebooks.length, "notebook", "notebooks");

resources.forEach((file) => {
const relPath = isAbsolute(file) ? relative(context.dir, file) : file;
Expand All @@ -307,6 +326,7 @@ export const createMecaBundle = async (
// Note to include in zip
manuscriptZipFiles.push(workingPath);
});
msg(resources.length, "other file", "other files");

// Generate a manifest
const articleItem = toMecaItem(articlePath, kArticleMetadata);
Expand All @@ -323,6 +343,8 @@ export const createMecaBundle = async (
],
};

info("");

// Write the manifest
const manifestFile = "manifest.xml";
const manifestXML = toXml(manifest);
Expand Down

0 comments on commit 0a2de51

Please sign in to comment.