Skip to content

Commit

Permalink
refact(web-node): Web is Web, and Node is Node.
Browse files Browse the repository at this point in the history
  • Loading branch information
hotoo committed Oct 9, 2015
1 parent a56182a commit 462c985
Show file tree
Hide file tree
Showing 14 changed files with 681 additions and 591 deletions.
29 changes: 9 additions & 20 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"no-bitwise": 2,
"no-caller": 2,
"no-catch-shadow": 2,
"no-comma-dangle": 0,
"no-cond-assign": [2, "except-parens"],
"no-constant-condition": 2,
"no-continue": 0,
Expand All @@ -31,7 +30,6 @@
"no-duplicate-case": 2,
"no-else-return": 0,
"no-empty": 2,
"no-empty-class": 0,
"no-empty-character-class": 2,
"no-empty-label": 2,
"no-eq-null": 0,
Expand All @@ -40,9 +38,8 @@
"no-extend-native": 2,
"no-extra-bind": 2,
"no-extra-boolean-cast": 2,
"no-extra-parens": 0,
"no-extra-parens": 2,
"no-extra-semi": 2,
"no-extra-strict": 2,
"no-fallthrough": 2,
"no-floating-decimal": 0,
"no-func-assign": 2,
Expand Down Expand Up @@ -82,17 +79,15 @@
"no-process-env": 0,
"no-process-exit": 0,
"no-proto": 2,
"no-redeclare": 0,
"no-redeclare": 2,
"no-regex-spaces": 2,
"no-reserved-keys": 0,
"no-restricted-modules": 0,
"no-return-assign": 0,
"no-script-url": 2,
"no-self-compare": 0,
"no-sequences": 2,
"no-shadow": 0,
"no-shadow-restricted-names": 2,
"no-space-before-semi": 0,
"no-spaced-func": 2,
"no-sparse-arrays": 2,
"no-sync": 0,
Expand All @@ -111,14 +106,14 @@
"no-unused-vars": 2,
"no-use-before-define": [2, "nofunc"],
"no-void": 0,
"no-var": 0,
"prefer-const": 0,
"no-var": 2,
"no-const-assign": 2,
"prefer-const": 2,
"no-warning-comments": [0, {
"terms": ["todo", "fixme", "xxx"],
"location": "start"
}],
"no-with": 2,
"no-wrap-func": 2,
"array-bracket-spacing": [0, "never"],
"accessor-pairs": 0,
"block-scoped-var": 0,
Expand All @@ -132,21 +127,19 @@
"consistent-return": 0,
"consistent-this": [0, "that"],
"constructor-super": 0,
"curly": [2, "all"],
"curly": [2, "multi-line"],
"default-case": 0,
"dot-location": 0,
"dot-notation": 0,
"eol-last": 2,
"eqeqeq": 2,
"func-names": 0,
"func-style": [0, "declaration"],
"generator-star": 0,
"generator-star-spacing": 0,
"global-strict": [0, "never"],
"guard-for-in": 0,
"handle-callback-err": 0,
"indent": 0,
"key-spacing": [0, {
"indent": [2, 2],
"key-spacing": [2, {
"beforeColon": false,
"afterColon": true
}],
Expand Down Expand Up @@ -174,12 +167,9 @@
"after": true
}],
"sort-vars": 0,
"space-after-function-name": [0, "never"],
"space-after-keywords": [0, "always"],
"space-before-blocks": [0, "always"],
"space-before-function-paren": [0, "always"],
"space-before-function-parentheses": [0, "always"],
"space-in-brackets": [0, "never"],
"space-in-parens": [0, "never"],
"space-infix-ops": 2,
"space-return-throw-case": 2,
Expand All @@ -188,8 +178,7 @@
"nonwords": false
}],
"spaced-comment": 0,
"spaced-line-comment": [0, "always"],
"strict": 0,
"strict": [2, "global"],
"use-isnan": 2,
"valid-jsdoc": 0,
"valid-typeof": 0,
Expand Down
12 changes: 5 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@ os:
language: node_js

node_js:
- "0.12"
- "4"
- "iojs-1"
- "iojs-2"
- "iojs-3"
- "4"

install:
- npm install spm coveralls mocha
- npm install spm coveralls

before_script:
- node_modules/spm/bin/spm-install
- npm install

script:
- node_modules/spm/bin/spm-test
- node_modules/.bin/mocha -R spec tests/detector-spec.js
- node_modules/.bin/mocha -R spec tests/morerule-test.js
- node_modules/.bin/mocha -R spec tests/detector-spec.js tests/morerule-test.js

after_success:
- node_modules/spm/bin/spm-test --coveralls | node_modules/.bin/coveralls
- cat coverage/lcov.info | node_modules/.bin/coveralls
29 changes: 16 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,28 @@ clean:
@rm -fr _site


runner = _site/tests/runner.html
lint:
@./node_modules/eslint/bin/eslint.js ./detector.js ./tests/ ./bin/detector


test-cli:
@mocha -R spec --timeout 5000 tests/cli.test.js

test-npm:
@mocha -R spec tests/detector-spec.js
@mocha -R spec tests/morerule-test.js
@./node_modules/.bin/istanbul cover \
./node_modules/.bin/_mocha \
-- \
--harmony \
--reporter spec \
--timeout 2000 \
--inline-diffs \
./tests/*.js


test-spm:
@spm test

lint:
@./node_modules/eslint/bin/eslint.js ./detector.js ./tests/ ./bin/detector

test: lint test-npm test-spm

output = _site/coverage.html
coverage: build-doc
@rm -fr _site/src-cov
@jscoverage --encoding=utf8 src _site/src-cov
@mocha-browser ${runner}?cov -S -R html-cov > ${output}
@echo "Build coverage to ${output}"


.PHONY: build-doc publish-doc server clean test coverage
19 changes: 11 additions & 8 deletions bin/detector
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#!/usr/bin/env node
var commander = require("commander");
var colors = require("colors");
var detector = require("../detector");

"use strict";

const commander = require("commander");
const colors = require("colors");
const detector = require("../lib/node-detector");

colors.setTheme({
label: "white",
Expand All @@ -23,11 +26,11 @@ if (commander.args.length === 0) {
commander.help();
}

var tan = detector.parse(commander.args.join(" "));
var device = tan.device.name.info + "@".red + tan.device.fullVersion.info;
var os = tan.os.name.info + "@".red + tan.os.fullVersion.info;
var browser = tan.browser.name.info + "@".red + tan.browser.fullVersion.info;
var engine = tan.engine.name.info + "@".red + tan.engine.fullVersion.info;
const tan = detector.parse(commander.args.join(" "));
const device = tan.device.name.info + "@".red + tan.device.fullVersion.info;
const os = tan.os.name.info + "@".red + tan.os.fullVersion.info;
const browser = tan.browser.name.info + "@".red + tan.browser.fullVersion.info;
const engine = tan.engine.name.info + "@".red + tan.engine.fullVersion.info;

console.log();
console.log(" Device: ".label, device);
Expand Down
3 changes: 1 addition & 2 deletions examples/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Thank you!

<pre id="ua"></pre>

<script type='text/spm'>
<script type="text/spm">
function isObject(obj){
return Object.prototype.toString.call(obj) === "[object Object]";
}
Expand All @@ -37,7 +37,6 @@ function expandObject(obj){
var $ = require('jquery');
var detector = require('detector');


var OS_ALIAS = {
// Windows.
"windows/4.0": "Windows 95",
Expand Down

0 comments on commit 462c985

Please sign in to comment.