-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (35 loc) · 931 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const Mustache = require("mustache");
const fs = require("fs");
const MUSTACHE_MAIN_DIR = "./main.mustache";
/**
* DATA is the object that contains all
* the data to be provided to Mustache
* Notice the "name" and "date" property.
*/
let DATA = {
name: "Matt",
fullname: "Matt Williams",
employer: "InfraHQ",
date: new Date().toLocaleDateString("en-US", {
weekday: "long",
month: "long",
day: "numeric",
hour: "numeric",
minute: "numeric",
timeZoneName: "short",
timeZone: "America/Los_Angeles",
}),
};
/**
* A - We open 'main.mustache'
* B - We ask Mustache to render our file with the data
* C - We create a README.md file with the generated output
*/
function generateReadMe() {
fs.readFile(MUSTACHE_MAIN_DIR, (err, data) => {
if (err) throw err;
const output = Mustache.render(data.toString(), DATA);
fs.writeFileSync("README.md", output);
});
}
generateReadMe();