UNPKG

500 BJavaScriptView Raw
1const fs = require('fs');
2const constants = require('constants');
3const path = require('path');
4
5var out = fs.createWriteStream(path.join(__dirname, 'dist', 'constants.js'));
6
7Object.keys(constants).forEach(function (key) {
8 var value = constants[key];
9 out.write(`export var ${key} = ${JSON.stringify(value)};\n`);
10});
11out.write('export default {\n ');
12Object.keys(constants).forEach(function (key, i) {
13 if (i) {
14 out.write(',\n ')
15 }
16 out.write(`${key}: ${key}`);
17});
18out.end('\n};\n');