diff --git a/.gitignore b/.gitignore index e5cfa53..fd5db51 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ sample-dist benchmark-dist yarn.lock node_modules +coverage.lcov diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..f51f692 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,10 @@ +language: + node_js +node_js: + - "10" +install: + - npm install +script: + - npm run lint + - npm run test + - npm run report-coverage diff --git a/README.md b/README.md index 9d6c248..07b3705 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ ## 使用高阶函数开发语法分析器 +[![travis-ci](https://api.travis-ci.org/muzea/parser.svg?branch=master)](https://travis-ci.org/muzea/parser) [![codecov](https://img.shields.io/codecov/c/github/muzea/parser/master.svg)](https://codecov.io/gh/muzea/parser) + 程序是[轮子哥博客](http://www.cppblog.com/vczh/archive/2008/05/21/50656.html)的js复刻版。 做了一些修改方便理解。~~其实是我看不懂轮子脚本的语法了~~ diff --git a/package.json b/package.json index e5069f7..18ba925 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "test": "nyc ava --color", "lint": "yarn tslint -p . && yarn eslint sample/*.js && yarn tslint sample/*.ts", "benchmark": "node ./benchmark-dist/json.js", - "benchmark:build": "parcel build benchmark/* -d benchmark-dist --target node" + "benchmark:build": "parcel build benchmark/* -d benchmark-dist --target node", + "report-coverage": "nyc ava --color && nyc report --reporter=text-lcov > coverage.lcov && codecov" }, "nyc": { "include": [ @@ -26,6 +27,7 @@ "devDependencies": { "ava": "1.2", "benchmark": "^2.1.4", + "codecov": "^3.2.0", "eslint": "^5.9.0", "eslint-plugin-prettier": "^3.0.0", "microtime": "^2.1.8", diff --git a/sample/json.ts b/sample/json.ts index 32abea5..2089932 100644 --- a/sample/json.ts +++ b/sample/json.ts @@ -449,8 +449,8 @@ function hexToValue(obj: Item): string { const codeMap = { '"': '\"', - '\\': '\\', '/': '\/', + '\\': '\\', 'b': '\b', 'n': '\n', 'r': '\r',