Skip to content
This repository has been archived by the owner on Dec 7, 2017. It is now read-only.

Commit

Permalink
Color the warning red when phantomjs isn't installed.
Browse files Browse the repository at this point in the history
  • Loading branch information
philipwalton committed Jan 22, 2014
1 parent 722967b commit 9c56bed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
16 changes: 11 additions & 5 deletions bin/html-inspector
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
#!/usr/bin/env node

require('colors')
require('shelljs/global')

// set the shelljs config
config.silent = true

var fs = require('fs')
, path = require('path')
, program = require('commander')
, shell = require('shelljs')

, inspectLocation
, configFile
, basePath = path.normalize(__dirname + path.sep + '..')
, version = JSON.parse(fs.readFileSync(path.join(basePath, "package.json"))).version
, phantomRunner = basePath + path.sep + 'bin' + path.sep + 'phantom-runner.js'


program
.version(version)
.usage('[options] <file or url>')
Expand All @@ -19,13 +25,13 @@ program

if(program.args.length !== 1) {
program.help()
process.exit()
exit()
}

// warn is PhantomJS isn't install
if (shell.exec("which phantomjs").code > 0) {
console.error("PhantomJS must be installed to use the HTML Inspector CLI.")
process.exit()
if (exec("which phantomjs").code !== 0) {
echo("PhantomJS must be installed to use the HTML Inspector CLI.".red)
exit(1)
}

// Try to resolve local file, otherwise assume and pass url
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"htmlinspector": "bin/html-inspector"
},
"dependencies": {
"commander": "*"
"commander": "*",
"colors": "*"
},
"devDependencies": {
"grunt": "*",
Expand All @@ -38,7 +39,6 @@
"dom-utils": "*",
"shelljs": "*",
"semver": "*",
"colors": "*",
"moment": "*"
}
}

0 comments on commit 9c56bed

Please sign in to comment.