{"size": 1835, "ext": "js", "max_stars_repo_path": "src/bundle-config.js", "max_stars_repo_name": "jeremiahsmall/carafe-bundler", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/bundle-config.js", "max_issues_repo_name": "jeremiahsmall/carafe-bundler", "max_issues_repo_issues_event_min_datetime": "2019-09-21T00:04:18.000Z", "max_issues_repo_issues_event_max_datetime": "2019-09-21T00:04:18.000Z", "max_forks_repo_path": "src/bundle-config.js", "max_forks_repo_name": "jeremiahsmall/carafe-bundler", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 31.1016949153, "max_line_length": 92, "alphanum_fraction": 0.6207084469}
const fs = require('fs');

class BundleConfig {
    constructor(workDir) {
        this.templateFilename = 'src/template.carafe';
        this.configFilename = 'src/config.json';
        this.dataFilename = 'src/data.json';
        this.metaFilename = 'src/meta.json';
        this.previewFilename = 'src/preview.jpg';
        this.librariesDirname = 'src/libraries';
        this.sendFmpUrl = 'fmp://$/Carafe?script=Send%20Carafe%20Bundle&param={sendConfig}';
        this.watchedFiles = {};

        if (!fs.existsSync(workDir + '/' + 'package.json')) {
            return;
        }

        const packageConfig = JSON.parse(fs.readFileSync(workDir + '/' + 'package.json'));

        if (!packageConfig.carafe) {
            return;
        }

        if (packageConfig.carafe.templateFilename) {
            this.templateFilename = packageConfig.carafe.templateFilename;
        }

        if (packageConfig.carafe.configFilename) {
            this.configFilename = packageConfig.carafe.configFilename;
        }

        if (packageConfig.carafe.dataFilename) {
            this.dataFilename = packageConfig.carafe.dataFilename;
        }

        if (packageConfig.carafe.metaFilename) {
            this.metaFilename = packageConfig.carafe.metaFilename;
        }

        if (packageConfig.carafe.previewFilename) {
            this.previewFilename = packageConfig.carafe.previewFilename;
        }

        if (packageConfig.carafe.librariesDirname) {
            this.librariesDirname = packageConfig.carafe.librariesDirname;
        }

        if (packageConfig.carafe.sendFmpUrl) {
            this.sendFmpUrl = packageConfig.carafe.sendFmpUrl;
        }

        if (packageConfig.carafe.watchedFiles) {
            this.watchedFiles = packageConfig.carafe.watchedFiles;
        }
    }
}

module.exports = BundleConfig;
