Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

put off refreshing env until later #197

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions lib/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var os = require('os')
var logger = require('../lib/logger').child({component: 'environment'})
var stringifySync = require('./util/safe-json').stringifySync


var loaded = false;
var exists = fs.existsSync || path.existsSync

/**
Expand Down Expand Up @@ -38,6 +38,10 @@ var remapping = {
var settings = []

function getSetting(name) {
if (!loaded) {
loaded = true
refresh()
}
var items = settings.filter(function cb_filter(candidate) {
return candidate[0] === name
}).map(function cb_map(setting) {
Expand All @@ -63,6 +67,10 @@ function addSetting(name, value) {
* @param {string} name
*/
function clearSetting(name) {
if (!loaded) {
loaded = true
refresh()
}
settings = settings.filter(function cb_filter(candidate) {
return candidate[0] !== name
})
Expand All @@ -76,6 +84,10 @@ function clearSetting(name) {
* @return array List of packages.
*/
function listPackages(root) {
if (!loaded) {
loaded = true
refresh()
}
var packages = []
if (existsDir(root)) {
packages = fs.readdirSync(root)
Expand Down Expand Up @@ -381,8 +393,6 @@ function refresh() {
remapConfigSettings()
findPackages()
}
// initialize settings
refresh()

/**
* Refreshes settings and returns the settings object.
Expand Down