-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(local): use the local version of webdriver-tool if it is installed
closes #5
- Loading branch information
Showing
7 changed files
with
80 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,29 @@ | ||
#!/usr/bin/env node | ||
|
||
require('../built/lib/webdriver.js'); | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
var chalk = require('chalk'); | ||
|
||
var Logger = require('../built/lib/cli/util').Logger; | ||
var Config = require('../built/lib/config').Config; | ||
|
||
var globalNpm = process.env.NPM_BIN || process.env.NVM_BIN; | ||
globalPath = path.resolve(globalNpm, '../lib/node_modules/webdriver-tool/built/lib/'); | ||
localPath = path.resolve(__dirname, '../node_modules/webdriver-tool/built/lib/'); | ||
|
||
try { | ||
if (fs.statSync(localPath).isDirectory()) { | ||
Logger.info('webdriver-tool: using ' + chalk.green('local version ' + Config.localVersion()));; | ||
} | ||
try { | ||
if (fs.statSync(globalPath).isDirectory()) { | ||
Logger.info('webdriver-tool: using ' + chalk.cyan('global version ' + Config.globalVersion())); | ||
} | ||
} catch (err) { } | ||
require(path.resolve(localPath, 'webdriver.js')); | ||
} | ||
// we are using the global version | ||
catch (err) { | ||
Logger.info('webdriver-tool: using ' + chalk.cyan('global version ' + Config.globalVersion())); | ||
require(path.resolve(globalPath, 'webdriver.js')); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import * as chalk from 'chalk'; | ||
|
||
export enum LOG_LEVEL { DEBUG, WARN, INFO } | ||
|
||
export class Logger { | ||
static info(message: string, opt_noTimestamp?: boolean): void { | ||
if (!opt_noTimestamp) { | ||
message = Logger.timestamp() + ' ' + message; | ||
} | ||
console.log(message); | ||
} | ||
|
||
static timestamp(): string { | ||
let d = new Date(); | ||
return '[' + chalk.gray(d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds()) + ']'; | ||
} | ||
} | ||
|
||
export class Req {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters