1 | const fs = require('fs');
|
2 | const path = require('path');
|
3 | const yaml = require('js-yaml');
|
4 | const ejs = require('ejs');
|
5 |
|
6 | module.exports = function (config, callback) {
|
7 | const url = path.resolve(process.cwd(), config);
|
8 |
|
9 | try {
|
10 |
|
11 | var rawConfig = yaml.safeLoad(fs.readFileSync(url, 'utf8'));
|
12 |
|
13 |
|
14 | var processedConfig = ejs.render(JSON.stringify(rawConfig), { ENV: process.env }, { cache: false });
|
15 |
|
16 |
|
17 | return JSON.parse(processedConfig);
|
18 | } catch (e) {
|
19 | throw new Error('Cannot parse configuration file. Please make sure your Swanky configuration file exists.');
|
20 | }
|
21 | }; |
\ | No newline at end of file |