1module.exports = {
2    writeVersion( contents ) {
3        const options = contents
4            .trim()
5            .split("\n")
6            .map(line => {
7                const indexOfFirstSpace = line.indexOf(' ');
8                return [line.slice(0, indexOfFirstSpace), line.slice(indexOfFirstSpace + 1)]
9                    .map( piece => piece.trim()) })
10            .reduce( (carry, [key, value]) => { return { ...carry, [key]: value};}, {} );
11
12        options.date = (new Date()).toISOString().substr(0, 10);
13
14        const longestKey = Object.keys(options).reduce( (carry, key) => Math.max(carry, key.length), 0);
15        return Object.entries(options)
16            .map( ([key, value]) => key.padEnd(longestKey) + ' ' + value)
17            .join("\n")
18            + "\n";
19    },
20};
21