Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.debug.js
*.min.js
node_modules/*
46 changes: 46 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"rules": {
"indent": [2, 2],
"quotes": [2, "single"],
"linebreak-style": [2, "unix"],
"semi": [2, "always"],
"strict": [2, "global"],
"curly": 2,
"eqeqeq": 2,
"no-eval": 2,
"guard-for-in": 2,
"no-caller": 2,
"no-else-return": 2,
"no-eq-null": 2,
"no-extend-native": 2,
"no-extra-bind": 2,
"no-floating-decimal": 2,
"no-implied-eval": 2,
"no-labels": 2,
"no-with": 2,
"no-loop-func": 1,
"no-native-reassign": 2,
"no-redeclare": [2, {"builtinGlobals": true}],
"no-delete-var": 2,
"no-shadow-restricted-names": 2,
"no-undef-init": 2,
"no-use-before-define": 2,
"no-unused-vars": [2, {"args": "none"}],
"no-undef": 2,
"callback-return": [2, ["callback", "cb", "next"]],
"global-require": 0,
"no-console": 0
},
"env": {
"es6": true,
"node": true,
"browser": true
},
"globals": {
"describe": true,
"it": true,
"before": true,
"after": true
},
"extends": "eslint:recommended"
}
43 changes: 0 additions & 43 deletions .jshintrc

This file was deleted.

4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
language: node_js
node_js:
- "0.11"
- "4"
- "6"
- "7"
script: make test-coveralls
17 changes: 7 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
TESTS = test/*.js
REPORTER = spec
TIMEOUT = 20000
ISTANBUL = ./node_modules/.bin/istanbul
PATH := ./node_modules/.bin:$(PATH)
MOCHA = ./node_modules/mocha/bin/_mocha
COVERALLS = ./node_modules/coveralls/bin/coveralls.js

test:
@NODE_ENV=test node --harmony \
$(MOCHA) -R $(REPORTER) -t $(TIMEOUT) \
$(MOCHA_OPTS) \
--harmony \
$(TESTS)
NODE_ENV=test mocha -R $(REPORTER) -t $(TIMEOUT) \
$(MOCHA_OPTS) $(TESTS)

test-cov:
@NODE_ENV=test node --harmony \
$(ISTANBUL) cover --report html $(MOCHA) -- -t $(TIMEOUT) -R spec $(TESTS)
@NODE_ENV=test \
istanbul cover --report html $(MOCHA) -- -t $(TIMEOUT) -R spec $(TESTS)

test-coveralls:
@NODE_ENV=test node --harmony \
$(ISTANBUL) cover --report lcovonly $(MOCHA) -- -t $(TIMEOUT) -R spec $(TESTS)
@NODE_ENV=test \
istanbul cover --report lcovonly $(MOCHA) -- -t $(TIMEOUT) -R spec $(TESTS)
@echo TRAVIS_JOB_ID $(TRAVIS_JOB_ID)
@cat ./coverage/lcov.info | $(COVERALLS) && rm -rf ./coverage

Expand Down
3 changes: 0 additions & 3 deletions index.js

This file was deleted.

9 changes: 5 additions & 4 deletions lib/wechat.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

var getRawBody = require('raw-body');
var xml2js = require('xml2js');
var crypto = require('crypto');
Expand All @@ -19,7 +21,7 @@ wechat.prototype.setToken = function (config) {
this.appid = config.appid || '';
this.encodingAESKey = config.encodingAESKey || '';
} else {
throw new Error('please check your config');
throw new TypeError('please check your config');
}
};

Expand Down Expand Up @@ -55,9 +57,8 @@ var formatMessage = function (result) {
message[key] = (val || '').trim();
}
} else {
message[key] = [];
result[key].forEach(function (item) {
message[key].push(formatMessage(item));
message[key] = result[key].map(function (item) {
return formatMessage(item);
});
}
}
Expand Down
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "co-wechat",
"version": "0.0.4",
"description": "wechat api for co",
"main": "index.js",
"main": "lib/wechat.js",
"scripts": {
"test": "make test-all"
},
Expand All @@ -27,13 +27,16 @@
"mocha": "*",
"should": "~3.0.0",
"expect.js": "*",
"koa": "0.13.*",
"koa": "^1.0.0",
"koa-generic-session": "*",
"travis-cov": "*",
"coveralls": "*",
"mocha-lcov-reporter": "*",
"muk": "*",
"rewire": "*",
"istanbul-harmony": "*"
}
"istanbul": "*"
},
"files": [
"lib"
]
}