Skip to content
This repository has been archived by the owner on Jun 15, 2019. It is now read-only.

Commit

Permalink
Use cdn for raw-git images.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamestalmage committed Dec 19, 2014
1 parent 77634ac commit dd96102
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 31 deletions.
2 changes: 1 addition & 1 deletion example.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@


##### feel free to use colors in your content strings, column widths will be calculated correctly
![table image](https://rawgit.com/jamestalmage/cli-table2/master/examples/screenshots/truncation-with-colors.png)
![table image](https://cdn.rawgit.com/jamestalmage/cli-table2/77634ac90faaccbf66002974192215e5349f4839/examples/screenshots/truncation-with-colors.png)
```javascript
var table = new Table({colWidths:[5],style:{head:[],border:[]}});

Expand Down
4 changes: 2 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ gulp.task('example',function(){
printExample.logExample(require('./examples/examples'));
});

gulp.task('example-md',function(){
printExample.mdExample(require('./examples/examples'),'example.md');
gulp.task('example-md',function(cb){
printExample.mdExample(require('./examples/examples'),'example.md',cb);
});

function coverage(opts){
Expand Down
61 changes: 33 additions & 28 deletions lib/print-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var expect = chai.expect;
var colors = require('colors/safe');
var _ = require('lodash');
var fs = require('fs');
var git = require('git-rev');

function runExample(fn,logName,logTable,logCode,logSeparator,screenshot){
function printExample(name,makeTable,expected){
Expand Down Expand Up @@ -47,39 +48,43 @@ function identity(str){
return str;
}

function mdExample(fn,file){
var buffer = [];
function mdExample(fn,file,cb){
git.long(function(commitHash){
var buffer = [];

runExample(fn,
function(name){
buffer.push('##### ' + name);
},
function(table){
table = stripColors(table);
runExample(fn,
function(name){
buffer.push('##### ' + name);
},
function(table){
table = stripColors(table);

if((table.indexOf('![table image]') == -1)){
table = ' ' + (table.split('\n').join('\n '));
if((table.indexOf('![table image]') == -1)){
table = ' ' + (table.split('\n').join('\n '));
}

buffer.push(table);
},
function(code){
buffer.push('```javascript');
buffer.push(stripColors(code));
buffer.push('```');
},
function(sep){
buffer.push(stripColors(sep));
},
function(makeTable,image){
return [
makeTable,
'![table image](https://cdn.rawgit.com/jamestalmage/cli-table2/' + commitHash + '/examples/screenshots/' + image + '.png)'
];
}
);

buffer.push(table);
},
function(code){
buffer.push('```javascript');
buffer.push(stripColors(code));
buffer.push('```');
},
function(sep){
buffer.push(stripColors(sep));
},
function(makeTable,image){
return [
makeTable,
'![table image](https://rawgit.com/jamestalmage/cli-table2/master/examples/screenshots/' + image + '.png)'
];
}
);
fs.writeFileSync(file,buffer.join('\n'));

fs.writeFileSync(file,buffer.join('\n'));
if(cb){cb();}
});
}

function testExample(name,fn,expected){
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"chai": "^1.10.0",
"cli-table": "^0.3.1",
"coveralls": "^2.11.2",
"git-rev": "^0.2.1",
"growl": "^1.8.1",
"gulp": "^3.8.10",
"gulp-istanbul": "^0.5.0",
Expand Down

0 comments on commit dd96102

Please sign in to comment.