test: put jscs as part of tests

Because, yes, I'd like a consistent code style!
This commit is contained in:
Remy Sharp 2015-07-28 13:40:09 +01:00
parent 27d9e8e8b0
commit aace364794
6 changed files with 23 additions and 11 deletions

View File

@ -2,7 +2,12 @@
"preset": "node-style-guide", "preset": "node-style-guide",
"requireCapitalizedComments": null, "requireCapitalizedComments": null,
"requireSpacesInAnonymousFunctionExpression": { "requireSpacesInAnonymousFunctionExpression": {
"beforeOpeningCurlyBrace": true "beforeOpeningCurlyBrace": true,
"beforeOpeningRoundBrace": true
}, },
"excludeFiles": ["node_modules/**"] "disallowSpacesInNamedFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"excludeFiles": ["node_modules/**"],
"disallowSpacesInFunction": null
} }

View File

@ -48,8 +48,10 @@ var argvKeys = Object.keys(argv).filter(function filter(item) {
}); });
if (!url && argvKeys.length === 0 || argv.help) { if (!url && argvKeys.length === 0 || argv.help) {
// show USAGE! var usage = require('fs').readFileSync(
console.log(require('fs').readFileSync(__dirname + '/../docs/usage.txt', 'utf8')); __dirname + '/../docs/usage.txt', 'utf8'
);
console.log(usage);
process.exit(0); process.exit(0);
} }

View File

@ -1,3 +1,4 @@
module.exports = { module.exports = {
ENOTFOUND: 'The URL could not be loaded, possibly a typo, or no internet connection', ENOTFOUND: 'The URL could not be loaded, possibly a typo, ' +
'or no internet connection',
}; };

View File

@ -68,7 +68,7 @@ function Inliner(url, options, callback) {
global.setImmediate = function setImmediatePolyfill(fn) { global.setImmediate = function setImmediatePolyfill(fn) {
// :-/ // :-/
setTimeout(fn, 0); setTimeout(fn, 0);
} };
} }
global.setImmediate(this.main.bind(this)); global.setImmediate(this.main.bind(this));
} }
@ -93,7 +93,7 @@ Inliner.prototype.main = main;
// static properties and methods // static properties and methods
Inliner.version = version; Inliner.version = version;
Inliner.errors = require('./errors'); Inliner.errors = require('./errors');
Inliner.defaults = function() { Inliner.defaults = function () {
return { return {
images: true, images: true,
compressCSS: true, compressCSS: true,
@ -177,7 +177,8 @@ function main() {
return inliner.get(url).then(function then(res) { return inliner.get(url).then(function then(res) {
var css = res.body; var css = res.body;
inliner.jobs.done.links(); inliner.jobs.done.links();
return inliner.cssImports(url, css).then(inliner.cssImages.bind(inliner, url)); return inliner.cssImports(url, css)
.then(inliner.cssImages.bind(inliner, url));
}).then(function then(css) { }).then(function then(css) {
$(link).replaceWith('<style>' + css + '</style>'); $(link).replaceWith('<style>' + css + '</style>');
}); });
@ -238,7 +239,8 @@ function main() {
}); });
} }
return promise.then(inliner.uglify.bind(inliner)).then(function then(res) { return promise.then(inliner.uglify.bind(inliner))
.then(function then(res) {
debug('uglify: %s', res); debug('uglify: %s', res);
$script.html(res); $script.html(res);
}); });

View File

@ -5,7 +5,7 @@
"homepage": "http://github.com/remy/inliner", "homepage": "http://github.com/remy/inliner",
"main": "lib/index.js", "main": "lib/index.js",
"scripts": { "scripts": {
"test": "node test/*.test.js --cov" "test": "jscs -v cli/*.js lib/*.js && node test/*.test.js --cov"
}, },
"keywords": [ "keywords": [
"mobile", "mobile",
@ -36,6 +36,7 @@
"inliner": "cli/index.js" "inliner": "cli/index.js"
}, },
"devDependencies": { "devDependencies": {
"jscs": "^2.0.0",
"st": "^0.5.5", "st": "^0.5.5",
"tap-spec": "^4.0.2", "tap-spec": "^4.0.2",
"tape": "^4.0.1" "tape": "^4.0.1"

View File

@ -13,7 +13,8 @@ test('inliner core functions', function coreTests(t) {
var Inliner = require('../'); var Inliner = require('../');
t.equal(typeof Inliner, 'function', 'Inliner is a function'); t.equal(typeof Inliner, 'function', 'Inliner is a function');
t.equal(Inliner.version, require('../package.json').version, 'should have version'); t.equal(Inliner.version,
require('../package.json').version, 'should have version');
var inliner = new Inliner(); var inliner = new Inliner();
t.ok(inliner, 'inline is instantiated'); t.ok(inliner, 'inline is instantiated');