-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild.js
33 lines (26 loc) · 857 Bytes
/
build.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
const YAML = require("yamljs");
const fs = require("fs");
var filePath = "./index.js";;
fs.unlinkSync(filePath);
console.log(process.env.npm_package_version);
let content = '/* AUTO GENERATED FILE DO NOT EDIT OR MAKE PRs FOR THIS FILE */\n\n';
// Load YAML file using YAML.load
nativeObject = YAML.load("providers.yml");
// definition
content += "const qrlNft = {";
// version from package.json
content += `"version":"${process.env.npm_package_version}", `;
// stringify YAML->JSON object
const json = JSON.stringify(nativeObject)
// chop out opening as we have already added version key
content += json.slice(1, json.length);
content += ';\n\n';
// export the object
content += 'module.exports = qrlNft;\n';
// try and write the file
try {
fs.writeFileSync(filePath, content);
//file written successfully
} catch (err) {
console.error(err);
}