Skip to content

Commit

Permalink
See #15. Remove shelljs dependency and fixed typos.
Browse files Browse the repository at this point in the history
  • Loading branch information
Glavin001 committed Jun 13, 2014
1 parent eacf232 commit a2dc4bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
11 changes: 7 additions & 4 deletions lib/atom-beautify.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ var path = require('path');
var nopt = require('nopt');
var extend = require('extend');
var _ = require('lodash');
var shjs = require('shelljs');

// TODO: Copied from jsbeautify, please update it from time to time
var knownOpts = {
Expand Down Expand Up @@ -82,6 +81,10 @@ function setCursors(editor, posArray) {
}
}

function verifyExists(fullPath) {
return fs.existsSync(fullPath) ? fullPath : null;
}

// Storage for memoized results from find file
// Should prevent lots of directory traversal &
// lookups when liniting an entire project
Expand All @@ -108,7 +111,7 @@ function findFile(name, dir) {

var parent = path.resolve(dir, '../');

if (shjs.test('-e', filename)) {
if (verifyExists(filename)) {
findFileResults[filename] = filename;
return filename;
}
Expand All @@ -124,7 +127,7 @@ function findFile(name, dir) {
/**
* Tries to find a configuration file in either project directory
* or in the home directory. Configuration files are named
* '.jshintrc'.
* '.jsbeautifyrc'.
*
* @param {string} config name of the configuration file
* @param {string} file path to the file to be linted
Expand All @@ -140,7 +143,7 @@ function findConfig(config, file) {
return proj;
}

if (shjs.test('-e', home)) {
if (verifyExists(home)) {
return home;
}

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"js-beautify": "~1.5.1",
"nopt": "^3.0.0",
"lodash": "2.4.1",
"shelljs": "^0.3.0",
"strip-json-comments": "^0.1.3"
}
}

0 comments on commit a2dc4bd

Please sign in to comment.