Skip to content

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
SBoudrias committed Oct 8, 2014
0 parents commit fe1c534
Show file tree
Hide file tree
Showing 9 changed files with 166 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
20 changes: 20 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"node": true,
"esnext": true,
"bitwise": true,
"curly": true,
"eqeqeq": true,
"eqnull": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"undef": true,
"strict": false,
"trailing": true,
"smarttabs": true,
"indent": 2,
"white": true,
"quotmark": "single",
"laxbreak": true
}
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
language: node_js
node_js:
- '0.10'
4 changes: 4 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env node
'use strict';

require('./doctor').run();
75 changes: 75 additions & 0 deletions doctor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
'use strict';

var path = require('path');
var chalk = require('chalk');
var shell = require('shelljs');

var doctor = module.exports = {
errors: [],

run: function () {
this.checkNodePath();
this.logErrors();
},

logErrors: function () {
if (!this.errors.length) {
console.log(chalk.green('[Yeoman Doctor] Everything looks all right!'));
console.log();
return;
}

console.log(chalk.red('[Yeoman Doctor] Uh oh, I found potential errors on your machine\n---------------\n'));
this.errors.forEach(function (errMsg) {
console.log('[' + chalk.red('Error') + '] ' + errMsg);
console.log();
});
},

checkNodePath: function () {
if (!process.env.NODE_PATH) {
return;
}

var nodePaths = process.env.NODE_PATH.split(path.delimiter).map(path.normalize);
var npmRoot = shell.exec('npm -g root', { silent: true }).output;

npmRoot = path.normalize(npmRoot.trim());

if (nodePaths.indexOf(npmRoot) < 0) {
this.nodePathMismatch({
nodePaths: nodePaths,
npmRoot: npmRoot
});
}
},

nodePathMismatch: function (val) {
var output = '';
output += 'npm root value is not in your NODE_PATH\n';
output += ' [' + chalk.cyan('info') + ']\n';
output += [
' NODE_PATH = ' + val.nodePaths.join(path.delimiter),
' npm root = ' + val.npmRoot
].join('\n');
output += '\n\n [' + chalk.cyan('Fix') + '] Append the npm root value to your NODE_PATH variable\n';

if (process.platform === 'win32') {
output += [
' If you\'re using cmd.exe, run this command to fix the issue:',
' setx NODE_PATH "%NODE_PATH%;' + val.npmRoot + '"',
' Then restart your command line. Otherwise, you can setup NODE_PATH manually:',
' https://github.com/sindresorhus/guides/blob/master/set-environment-variables.md#windows'
].join('\n');
} else {
output += [
' Add this line to your .bashrc',
' export NODE_PATH=$NODE_PATH:' + val.npmRoot,
' Or run this command',
' echo "export NODE_PATH=$NODE_PATH:' + val.npmRoot + '" >> ~/.bashrc && source ~/.bashrc'
].join('\n');
}

this.errors.push(output);
}
};
33 changes: 33 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "yeoman-doctor",
"version": "0.0.0",
"description": "Script to detect potential issues who'd break Yeoman on a user machine",
"license": "BSD",
"main": "doctor.js",
"bin": {
"yodoctor": "cli.js"
},
"author": "The Yeoman Team",
"repository": "yeoman/doctor",
"engines": {
"node": ">=0.10.0",
"npm": ">=1.4.3"
},
"scripts": {
"test": "jshint doctor.js"
},
"files": [
"doctor.js",
"cli.js"
],
"keywords": [
"yeoman"
],
"dependencies": {
"chalk": "^0.5.1",
"shelljs": "^0.3.0"
},
"devDependencies": {
"jshint": "^2.5.6"
}
}
17 changes: 17 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Yeoman Doctor [![Build Status](https://travis-ci.org/yeoman/doctor.svg?branch=master)](https://travis-ci.org/yeoman/doctor)



## Usage

Use as part of yo

```
yo doctor
```

If installed globally on your machine, you can also call `yodoctor`

## License

[BSD license](http://opensource.org/licenses/bsd-license.php) and copyright Google.

0 comments on commit fe1c534

Please sign in to comment.