diff --git a/lib/get_component_file.js b/lib/get_component_file.js index 58eaa9f..de946d1 100755 --- a/lib/get_component_file.js +++ b/lib/get_component_file.js @@ -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); +} diff --git a/lib/get_component_name.js b/lib/get_component_name.js index 05462cc..d17d981 100755 --- a/lib/get_component_name.js +++ b/lib/get_component_name.js @@ -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('-'); @@ -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)); +}