Skip to content

Commit

Permalink
Suppress errors when operating on a non-project directory
Browse files Browse the repository at this point in the history
  • Loading branch information
mzabriskie committed Jul 15, 2015
1 parent 679ae0e commit 166348e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/get_component_file.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/usr/bin/env node

var path = require('path');
console.log(require(path.join(process.cwd(), 'package.json')).name);
var fs = require('fs');
var file = path.join(process.cwd(), 'package.json');

if (fs.existsSync(file)) {
console.log(require(file).name);
}
6 changes: 5 additions & 1 deletion lib/get_component_name.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env node

var path = require('path');
var fs = require('fs');
var file = path.join(process.cwd(), 'package.json');

function PascalCase(str) {
var parts = str.split('-');
Expand All @@ -10,4 +12,6 @@ function PascalCase(str) {
return parts.join('');
}

console.log(PascalCase(require(path.join(process.cwd(), 'package.json')).name));
if (fs.existsSync(file)) {
console.log(PascalCase(require(file).name));
}

0 comments on commit 166348e

Please sign in to comment.