-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fix access access to file on remote location (like hadoop/HDFS) - add test for accessing files over network - 2 spaces instead 4
- Loading branch information
Showing
7 changed files
with
3,170 additions
and
66 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 |
---|---|---|
|
@@ -3,7 +3,7 @@ os: osx | |
language: node_js | ||
osx_image: xcode8.2 | ||
node_js: | ||
- '6' | ||
- '8' | ||
env: | ||
- CXX=g++-4.8 | ||
addons: | ||
|
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,22 +1,27 @@ | ||
#!/usr/bin/env node | ||
|
||
const errMsg = require('./errorMsg') | ||
const version = require('./package.json').version | ||
const argv = require('yargs') | ||
.usage('Usage: $0 [url|file] --cols [num] --ratio [num]') | ||
.option('c', { | ||
alias: 'cols', | ||
default: 80, | ||
describe: 'Number of columns in terminal' | ||
}) | ||
.option('r', { | ||
alias: 'ratio', | ||
default: 1, | ||
describe: 'Aspect ratio. Try 0.5 to flatten image\nand 2 to lengthen image' | ||
}) | ||
.demand(1) | ||
.argv | ||
.usage('Usage: $0 [url|file] --cols [num] --ratio [num]') | ||
.option('c', { | ||
alias: 'cols', | ||
default: 80, | ||
describe: 'Number of columns in terminal' | ||
}) | ||
.option('r', { | ||
alias: 'ratio', | ||
default: 1, | ||
describe: 'Aspect ratio. Try 0.5 to flatten image\nand 2 to lengthen image' | ||
}) | ||
.option('v', { | ||
alias: 'version', | ||
describe: `Prints version: ${version}` | ||
}) | ||
.demand(1) | ||
.argv | ||
|
||
process.on('uncaughtException', errMsg.printErr) | ||
|
||
const img2ascii = require('./img2ascii')(argv) | ||
.pipe(process.stdout) | ||
.pipe(process.stdout) |
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,17 +1,16 @@ | ||
module.exports.printErr = function (err) { | ||
module.exports.printErr = (err) => { | ||
|
||
console.error('Error:') | ||
console.error('Error:') | ||
|
||
if ('ENOENT' === err.code && 'open' !== err.syscall) { | ||
console.error('Please install graphicsmagick:') | ||
console.error('brew install graphicsmagick') | ||
console.error('sudo apt-get install graphicsmagick') | ||
} | ||
if ('ENOENT' === err.code && 'open' !== err.syscall) { | ||
console.error('Please install graphicsmagick:') | ||
console.error('brew install graphicsmagick') | ||
console.error('sudo apt-get install graphicsmagick') | ||
} | ||
|
||
if ('ENOTFOUND' === err.code) { | ||
console.log('Please check your uri / network connection') | ||
} | ||
|
||
console.dir(err.message) | ||
if ('ENOTFOUND' === err.code) { | ||
console.log('Please check your uri / network connection') | ||
} | ||
|
||
console.dir(err.message) | ||
} |
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,22 +1,22 @@ | ||
module.exports = function img2ascii(config) { | ||
const argv = { | ||
ratio: config.ratio, | ||
cols: config.cols, | ||
_: config._ || [config.img] | ||
} | ||
const gm = require('gm') | ||
const pictureTube = require('picture-tube') | ||
module.exports = (config) => { | ||
const argv = { | ||
ratio: config.ratio, | ||
cols: config.cols, | ||
_: config._ || [config.img] | ||
} | ||
const gm = require('gm') | ||
const pictureTube = require('picture-tube') | ||
|
||
const isUrl = (str) => str.match('http|0.0|localhost') | ||
const isUrl = (str) => str.match(/^http|0\.0|1..\.|localhost/) | ||
|
||
const pipeIn = (isUrl(argv._[0]) ? | ||
require('request-promise')(argv._[0]) : | ||
require('fs').createReadStream(argv._[0])) | ||
const pipeIn = (isUrl(argv._[0]) ? | ||
require('request-promise')(argv._[0]) : | ||
require('fs').createReadStream(argv._[0])) | ||
|
||
return gm(pipeIn) | ||
// magic fix of picture tube ratios | ||
.resizeExact(300 * 1.2, 300 * argv.ratio) | ||
.stream('png') | ||
.pipe(pictureTube({cols: argv.cols})) | ||
return gm(pipeIn) | ||
// magic fix of picture tube ratios | ||
.resizeExact(300 * 1.2, 300 * argv.ratio) | ||
.stream('png') | ||
.pipe(pictureTube({ cols: argv.cols })) | ||
} | ||
|
Oops, something went wrong.