Skip to content

Commit

Permalink
Merge pull request #76 from RallyApps/stop_saving_config
Browse files Browse the repository at this point in the history
Stop trying to resave the config file all the time
  • Loading branch information
krmorse committed Jun 20, 2017
2 parents 5bd0e2f + 2e4d166 commit 837c93a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 34 deletions.
11 changes: 2 additions & 9 deletions lib/config.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,14 @@ pathUtils = require('path')

configFileName = "config.json"

_updateConfig = (config)->
config.server = config.server || "https://rally1.rallydev.com"
config

saveConfig = ({path, config}, callback)->
configPath = pathUtils.join(path, configFileName)
fs.writeFile(configPath, JSON.stringify(config, null, ' '), callback)

getConfig = (path, callback) ->
convertToJson = (error, file)->
if !error
config = JSON.parse(file)
_updateConfig(config)
saveConfig({config, path})
callback(null, config)
callback(null, JSON.parse(file))
else
callback(error)

Expand All @@ -39,5 +32,5 @@ getAppSourceRoot = (path, callback) ->
common = pathUtils.resolve common, '..'
callback null, common

module.exports = {_updateConfig,getConfig,saveConfig,getAppSourceRoot}
module.exports = {getConfig,saveConfig,getAppSourceRoot}
_.defaults module.exports, {configFileName}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "Kyle Morse <[email protected]>",
"name": "rally-app-builder",
"description": "A node module that assists in the building of Rally Apps",
"version": "1.6.1",
"version": "1.6.2",
"homepage": "https://github.com/rallyapps/rally-app-builder",
"repository": {
"type": "git",
Expand Down
24 changes: 0 additions & 24 deletions test/config.test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,6 @@ config = require '../lib/config'
path = require 'path'

describe 'Config', ()->
describe('Updates Config', ()->
testConfig = {
"name": "CardboardCustomCard",
"className": "CustomApp",
"sdk": "2.0p5",
"javascript": [
"CustomCard.js",
"App.js",
"TestCoffee.coffee"
],
"css": [
"app.css"
],
"parents": [
"ferentchak/teamboard",
"rallyapps/ninjas"
]
}

updatedConfig = config._updateConfig(testConfig)
it "should add a server to the config file if one is not present",
()->
assert(updatedConfig.server == "https://rally1.rallydev.com")
)

describe '#getAppSourceRoot', () ->

Expand Down

0 comments on commit 837c93a

Please sign in to comment.