Skip to content

Commit

Permalink
refactor: HTML pulling down, events, images
Browse files Browse the repository at this point in the history
  • Loading branch information
remy committed Jul 26, 2015
1 parent c940480 commit 16944df
Show file tree
Hide file tree
Showing 11 changed files with 361 additions and 684 deletions.
8 changes: 8 additions & 0 deletions .jscsrc
@@ -0,0 +1,8 @@
{
"preset": "node-style-guide",
"requireCapitalizedComments": null,
"requireSpacesInAnonymousFunctionExpression": {
"beforeOpeningCurlyBrace": true
},
"excludeFiles": ["node_modules/**"]
}
16 changes: 16 additions & 0 deletions .jshintrc
@@ -0,0 +1,16 @@
{
"browser": true,
"camelcase": true,
"curly": true,
"devel": true,
"eqeqeq": true,
"forin": true,
"indent": 2,
"noarg": true,
"node": true,
"quotmark": "single",
"undef": true,
"strict": false,
"unused": true
}

108 changes: 0 additions & 108 deletions bin/inliner

This file was deleted.

81 changes: 81 additions & 0 deletions cli/index.js
@@ -0,0 +1,81 @@
#!/usr/bin/env node
var argv = require('minimist')(process.argv.slice(2), {
alias: {
V: 'version',
h: 'help',
d: 'debug',
v: 'verbose',
i: 'images',
n: 'nocompress',
},
});

if (argv.debug) {
require('debug').enable('inliner');
}

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

// checks for available update and returns an instance
// var updateNotifier = require('update-notifier');
// var pkg = require('../package.json');
// var notifier = updateNotifier({ pkg: pkg });
// if (notifier.update) {
// // notify using the built-in convenience method
// notifier.notify();
// }

var url = argv._.shift();

var argvKeys = Object.keys(argv).filter(function (item) {
return item !== '_';
});

if (!url && argvKeys.length === 0 || argv.help) {
// show USAGE!
console.log(' Examples:');
console.log('');
console.log(' $ inliner -v http://twitter.com > twitter.html');
console.log(' $ inliner -ni http://twitter.com > twitter.html');
console.log('');
console.log(' For more details see http://github.com/remy/inliner/');
console.log('');
process.exit(0);
}

if (argv.version) {
console.log(Inliner.version);
}

var options = Inliner.defaults();

if (argv.nocompress) {
options.compressCSS = false;
options.collapseWhitespace = false;
}

options.images = !argv.images;

var inliner = new Inliner(url, argv, function result(error, html) {
if (error) {
var message = Inliner.errors[error.code] || error.message;
console.error(message);

if (argv.debug) {
console.error(error.stack);
}

process.exit(1);
}
console.log(html);
});

if (argv.verbose) {
inliner.on('progress', function progress(event) {
console.error(event);
});

inliner.on('jobs', function jobs(event) {
console.error(event);
});
}

0 comments on commit 16944df

Please sign in to comment.