From c4422a171c4b702fe24d1d49e1a6ce37f7b02880 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Mon, 22 Dec 2014 14:45:16 -0400 Subject: [PATCH] Remove unused config module --- lib/resin/config/config.coffee | 32 ------------------ lib/resin/config/config.spec.coffee | 50 ----------------------------- 2 files changed, 82 deletions(-) delete mode 100644 lib/resin/config/config.coffee delete mode 100644 lib/resin/config/config.spec.coffee diff --git a/lib/resin/config/config.coffee b/lib/resin/config/config.coffee deleted file mode 100644 index 1bc17cc2..00000000 --- a/lib/resin/config/config.coffee +++ /dev/null @@ -1,32 +0,0 @@ -fs = require('fs') -errors = require('../errors/errors') - -# Read JSON configuration file -# -# @private -# -# User config loading should be sync, as we need to -# extend this module with the result before exporting -# -# @param {String} configFile configuration file path -# @return {Object} Parsed configuration file -# -# @throw {InvalidConfigFile} Will throw an error if file doesn't exist -# @throw {InvalidConfigFile} Will throw an error if file is not JSON -# -# @example Read config file -# contents = resin.config.loadUserConfig('/Users/me/resin-custom.json') -# console.log(contents.remoteUrl) -# -exports.loadUserConfig = (configFile) -> - return if not fs.existsSync(configFile) - - if not fs.statSync(configFile).isFile() - throw new errors.InvalidConfigFile(configFile) - - result = fs.readFileSync(configFile, encoding: 'utf8') - - try - return JSON.parse(result) - catch error - throw new errors.InvalidConfigFile(configFile) diff --git a/lib/resin/config/config.spec.coffee b/lib/resin/config/config.spec.coffee deleted file mode 100644 index 707429c2..00000000 --- a/lib/resin/config/config.spec.coffee +++ /dev/null @@ -1,50 +0,0 @@ -_ = require('lodash') -chai = require('chai') -expect = chai.expect -config = require('./config') -mock = require('../../../tests/utils/mock') - -FILESYSTEM = - config: - name: 'config' - contents: JSON.stringify - directories: - plugins: 'myPlugins' - remoteUrl: 'http://localhost:9001' - directoryConfig: - name: 'directoryConfig' - contents: {} - notJSON: - name: 'notJSON' - contents: 'Not JSON content' - -describe 'Config:', -> - - beforeEach -> - mock.fs.init(FILESYSTEM) - - afterEach -> - mock.fs.restore() - - describe '#loadUserConfig()', -> - - it 'should load the default config file', -> - configFile = FILESYSTEM.config.name - result = config.loadUserConfig(configFile) - expectedContents = JSON.parse(FILESYSTEM.config.contents) - expect(result).to.deep.equal(expectedContents) - - it 'should return undefined if config file does not exist', -> - configFile = 'foobar' - result = config.loadUserConfig(configFile) - expect(result).to.be.undefined - - it 'should throw an error if config file is not a file', -> - configFile = FILESYSTEM.directoryConfig.name - func = _.partial(config.loadUserConfig, configFile) - expect(func).to.throw(Error) - - it 'should throw an error if config is not a json file', -> - configFile = FILESYSTEM.notJSON.name - func = _.partial(config.loadUserConfig, configFile) - expect(func).to.throw(Error)