Skip to content

Commit

Permalink
chore: <ci> test and cov
Browse files Browse the repository at this point in the history
  • Loading branch information
x-cold committed Aug 29, 2018
1 parent e0513ac commit ea67d43
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
@@ -0,0 +1,2 @@
node_modules/
coverage/
6 changes: 6 additions & 0 deletions .eslintrc
@@ -0,0 +1,6 @@
{
"extends": "eslint-config-egg",
"parserOptions": {
"ecmaVersion": 2017
}
}
12 changes: 12 additions & 0 deletions .travis.yml
@@ -0,0 +1,12 @@
sudo: false
language: node_js
node_js:
- '8'
- '9'
- '10'
install:
- npm i npminstall && npminstall
script:
- npm run ci
after_script:
- npminstall codecov && codecov
46 changes: 42 additions & 4 deletions README.md
@@ -1,6 +1,26 @@
# yuque-hexo
A downloader for articles from yuque

[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Test coverage][codecov-image]][codecov-url]
[![David deps][david-image]][david-url]
[![Known Vulnerabilities][snyk-image]][snyk-url]
[![npm download][download-image]][download-url]

[npm-image]: https://img.shields.io/npm/v/yuque-hexo.svg?style=flat-square
[npm-url]: https://npmjs.org/package/yuque-hexo
[travis-image]: https://img.shields.io/travis/x-cold/yuque-hexo.svg?style=flat-square
[travis-url]: https://travis-ci.org/x-cold/yuque-hexo
[codecov-image]: https://codecov.io/gh/x-cold/yuque-hexo/branch/master/graph/badge.svg
[codecov-url]: https://codecov.io/gh/x-cold/yuque-hexo
[david-image]: https://img.shields.io/david/x-cold/yuque-hexo.svg?style=flat-square
[david-url]: https://david-dm.org/x-cold/yuque-hexo
[snyk-image]: https://snyk.io/test/npm/yuque-hexo/badge.svg?style=flat-square
[snyk-url]: https://snyk.io/test/npm/yuque-hexo
[download-image]: https://img.shields.io/npm/dm/yuque-hexo.svg?style=flat-square
[download-url]: https://npmjs.org/package/yuque-hexo

A downloader for articles from yuque

# Usage

Expand All @@ -23,6 +43,8 @@ A downloader for articles from yuque

```
npm i -g yuque-hexo
# or
npm i --save-dev yuque-hexo
```

## Sync
Expand All @@ -37,12 +59,28 @@ yuque-hexo sync
yuque-hexo clean
```

## Npm Scripts

```json
{
"dev": "npm run sync && hexo s",
"sync": "yuque-hexo sync",
"clean:yuque": "yuque-hexo clean"
}
```

## Debug

```
DEBUG=yuque-hexo.* yuque-hexo sync
```

# Notice

语雀同步过来的文章会生成两块文件
语雀同步过来的文章会生成两部分文件

- yuque.json 从语雀 API 拉取的数据
- source/_posts/yuque/*.md 生成的 md 文件
- yuque.json: 从语雀 API 拉取的数据
- source/_posts/yuque/*.md: 生成的 md 文件

# Example

Expand Down
14 changes: 14 additions & 0 deletions appveyor.yml
@@ -0,0 +1,14 @@
environment:
matrix:
- nodejs_version: '6'

install:
- ps: Install-Product node $env:nodejs_version
- npm i npminstall && node_modules\.bin\npminstall

test_script:
- node --version
- npm --version
- npm run test

build: off
8 changes: 8 additions & 0 deletions test/hexo-project/package.json
@@ -0,0 +1,8 @@
{
"name": "your-hexo-project",
"yuqueConfig": {
"baseUrl": "https://www.yuque.com/api/v2",
"login": "yinzhi",
"repo": "blog"
}
}
60 changes: 60 additions & 0 deletions test/yuque.test.js
@@ -0,0 +1,60 @@
'use strict';

const path = require('path');
const coffee = require('coffee');
const assert = require('assert');

describe('test/my-git.test.js', () => {
const myBin = require.resolve('../bin/yuque-hexo');
const cwd = path.join(__dirname, 'hexo-project');

describe('global options', () => {
it('yuque-hexo --help', async () => {
const { stdout, code } = await coffee
.fork(myBin, [ '--help' ], { cwd })
.end();
assert(stdout.includes('Usage: yuque-hexo <command>'));
assert(code === 0);
});

it('yuque-hexo clean with warning', async () => {
const { stdout, code } = await coffee
.fork(myBin, [ 'clean' ], { cwd })
.end();
assert(stdout.includes('yuque-hexo clean start.'));
assert(stdout.includes('yuque-hexo clean finished.'));
assert(stdout.includes('WARNING'));
assert(code === 0);
});

it('yuque-hexo without cache', async () => {
const { stdout, code } = await coffee
.fork(myBin, [ 'sync' ], { cwd })
.end();
assert(stdout.includes('yuque-hexo sync start.'));
assert(stdout.includes('download article body'));
assert(stdout.includes('yuque-hexo sync finished.'));
assert(code === 0);
});

it('yuque-hexo sync use cache', async () => {
const { stdout, code } = await coffee
.fork(myBin, [ 'sync' ], { cwd })
.end();
assert(stdout.includes('yuque-hexo sync start.'));
assert(!stdout.includes('download article body'));
assert(stdout.includes('yuque-hexo sync finished.'));
assert(code === 0);
});

it('yuque-hexo clean', async () => {
const { stdout, code } = await coffee
.fork(myBin, [ 'clean' ], { cwd })
.end();
assert(stdout.includes('yuque-hexo clean start.'));
assert(stdout.includes('yuque-hexo clean finished.'));
assert(!stdout.includes('WARNING'));
assert(code === 0);
});
});
});

0 comments on commit ea67d43

Please sign in to comment.