Skip to content

Commit

Permalink
Extract truncate to own file
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewn committed Jun 1, 2016
1 parent 488d498 commit 242f6b7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
10 changes: 2 additions & 8 deletions lib/browserstack-automate.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ var ora = require('ora');
var chalk = require('chalk');
var debug = require('debug')('backend:debug');

var truncate = require('./truncate');

function createErrorHandler(msg) {
return function (err) {
console.error(chalk.red(msg));
Expand Down Expand Up @@ -167,14 +169,6 @@ module.exports = function (credentials, options) {
);
}

function truncate(str, limit) {
if (str.length > limit) {
return str.slice(0, limit) + '…';
} else {
return str;
}
}

function takeScreenshotForUrlAtWidths(url, widths, count) {
spinner = ora({
text: 'Navigating to: ' + chalk.bold.underline( truncate(url, 100) ),
Expand Down
7 changes: 7 additions & 0 deletions lib/truncate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = function truncate(str, limit) {
if (str.length > limit) {
return str.slice(0, limit) + '…';
} else {
return str;
}
}

0 comments on commit 242f6b7

Please sign in to comment.