Permalink
Browse files

Merge pull request #19 from jwagner/master

Defining predef in the default values for homerc
  • Loading branch information...
2 parents 3cf3b3d + d972db9 commit 6321a48e0c5edf54c455a7e1b107177a38a3b1e2 @brentlintner brentlintner committed May 25, 2011
Showing with 24 additions and 6 deletions.
  1. +2 −1 .gitignore
  2. +5 −1 README.md
  3. +17 −4 lib/cli.js
View
3 .gitignore
@@ -1 +1,2 @@
-tags
+tags
+node_modules
View
6 README.md
@@ -31,11 +31,15 @@ The cli uses the default options that come with jshint, however if it locates a
If there is a .jshintrc file in the current working directory, it will be merged into the default options.
-## Running Tests
+## Installing dependencies for development
+ npm install argparser@0.03
git submodule init
git submodule update
+
+## Running Tests
+
npm install jasmine-node
jake test
View
21 lib/cli.js
@@ -15,13 +15,23 @@ function _mergeConfigs(homerc, cwdrc) {
cwdConfig = {},
prop;
- if (_path.existsSync(homerc)) homeConfig = JSON.parse(_fs.readFileSync(homerc, "utf-8"));
- if (_path.existsSync(cwdrc)) cwdConfig = JSON.parse(_fs.readFileSync(cwdrc, "utf-8"));
+ try{
+ if (_path.existsSync(homerc)) homeConfig = JSON.parse(_fs.readFileSync(homerc, "utf-8"));
+ } catch (e) {
+ _sys.puts("Error opening config file " + homerc + '\n');
+ _sys.puts(e + "\n");
+ }
+ try{
+ if (_path.existsSync(cwdrc)) cwdConfig = JSON.parse(_fs.readFileSync(cwdrc, "utf-8"));
+ } catch (e) {
+ _sys.puts("Error opening config file " + cwdrc + '\n');
+ _sys.puts(e + "\n");
+ }
for (prop in cwdConfig) {
if (typeof prop === 'string') {
if (prop === 'predef') {
- homeConfig.predef = homeConfig.predef.concat(cwdConfig.predef);
+ homeConfig.predef = (homeConfig.predef || []).concat(cwdConfig.predef);
} else {
homeConfig[prop] = cwdConfig[prop];
}
@@ -66,7 +76,10 @@ module.exports = {
} else {
try {
config = _mergeConfigs(defaultConfig, projectConfig);
- } catch (f) {}
+ } catch (f) {
+ _sys.puts("Error opening config file " + defaultConfig + " or " + projectConfig);
+ _sys.puts(e + "\n");
+ }
}
if (customReporter) {

0 comments on commit 6321a48

Please sign in to comment.