Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
md-template
Advanced tools
Readme
Build markdown from es6-templates and js
All js files will be executed and exported object will be deeply merged together in order. This data will be made available to the template.
md-template ./template.md ./data.js > README.md
module.exports = () => {
const { execSync } = require("child_process");
const fs = require("fs");
const path = require("path");
const os = require("os");
const uuid = require("uuid/v1");
const expected = `
# one
1
## two
2
## RGB
red green blue
`;
const template = `
# one
\${one}
## two
\${two}
## RGB
\${color_channels.slice(0,3).join(" ")}
`; // NOTE: backslashes not neccissary in actual file
const data = `
module.exports = {
one: 1,
two: 2,
color_channels: ["red", "green", "blue", "alpha"]
};
`;
const demoDir = path.join(os.tmpdir(), uuid());
fs.mkdirSync(demoDir);
const templatePath = path.join(demoDir, "template.md");
const dataPath = path.join(demoDir, "data.js");
fs.writeFileSync(templatePath, template);
fs.writeFileSync(dataPath, data);
const result = execSync(`node cli.js ${templatePath} ${dataPath}`, {
encoding: "utf8"
});
return result === expected;
};
md-template:
type: object
example: md-template <TEMPLATE> <...DATA> [options]
description: >
Generates document from templated object and exported data.
Prints new document to stdout
properties:
TEMPLATE:
type: string
example: template.md
description: >
Path to document whose text content will be used as
a template string
DATA:
type: array
description: >
Paths to json files which will be required,
properties exported by these scripts will
be deeply merged in the order in the command
and made available to template
items:
type: string
example: data.js
options:
type: object
properties:
"-h":
type: boolean
description: >
When present, prints help file to stderr
and returns non-0 exit code
module.exports = async () => {
const { execSync } = require("child_process");
const fs = require("fs");
const path = require("path");
const os = require("os");
const uuid = require("uuid/v1");
const expected = `
# one
1
## two
2
## RGB
red green blue
`;
const template = `
# one
\${one}
## two
\${two}
## RGB
\${color_channels.slice(0,3).join(" ")}
`; // NOTE: backslashes not neccissary in actual file
const data = `
module.exports = {
one: 1,
two: 2,
color_channels: ["red", "green", "blue", "alpha"]
};
`;
const demoDir = path.join(os.tmpdir(), uuid());
fs.mkdirSync(demoDir);
const templatePath = path.join(demoDir, "template.md");
const dataPath = path.join(demoDir, "data.js");
fs.writeFileSync(templatePath, template);
fs.writeFileSync(dataPath, data);
const results = await require("../index")({
templatePath: templatePath,
scriptPaths: [dataPath]
});
return results === expected;
};
type: string
path to template file
type: string | array
paths of scripts which will be executed and their results deeply merged together in order, and this data will be available to the template
FAQs
Build markdown from es6-templates and js
The npm package md-template receives a total of 1 weekly downloads. As such, md-template popularity was classified as not popular.
We found that md-template demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.