From 1a637a04ea809d127a771810c30fbb18e08ca388 Mon Sep 17 00:00:00 2001 From: Mimi <1119186082@qq.com> Date: Wed, 31 Mar 2021 08:55:20 +0800 Subject: [PATCH] chore: drop Node.js 10 (#59) --- .github/workflows/linter.yml | 20 ++++++++++++++++ .github/workflows/tester.yml | 46 ++++++++++++++++++++++++++++++++++++ .gitignore | 3 ++- .travis.yml | 21 ---------------- lib/generator.js | 3 +-- package.json | 7 +++--- 6 files changed, 72 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/linter.yml create mode 100644 .github/workflows/tester.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml new file mode 100644 index 0000000..6dc94c7 --- /dev/null +++ b/.github/workflows/linter.yml @@ -0,0 +1,20 @@ +name: Linter + +on: [push, pull_request] + +jobs: + linter: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Use Node.js 14.x + uses: actions/setup-node@v2 + with: + node-version: '14.x' + - name: Install Dependencies + run: npm install + - name: Lint + run: | + npm run eslint + env: + CI: true diff --git a/.github/workflows/tester.yml b/.github/workflows/tester.yml new file mode 100644 index 0000000..dd848c8 --- /dev/null +++ b/.github/workflows/tester.yml @@ -0,0 +1,46 @@ +name: Tester + +on: [push, pull_request] + +jobs: + tester: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + node-version: ['12.x', '14.x'] + fail-fast: false + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + - name: Install Dependencies + run: npm install + - name: Test + run: npm run test + env: + CI: true + coverage: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + node-version: ['14.x'] + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + - name: Install Dependencies + run: npm install + - name: Coverage + run: npm run test-cov + env: + CI: true + - name: Coveralls + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.github_token }} diff --git a/.gitignore b/.gitignore index 0cbd2b4..ed220ca 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ node_modules/ tmp/ *.log .idea/ -.nyc_output/ \ No newline at end of file +.nyc_output/ +coverage/ \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e6d47c8..0000000 --- a/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -language: node_js - -sudo: false - -cache: - apt: true - directories: - - node_modules - -node_js: - - "10" - - "12" - - "node" - -script: - - npm run eslint - - npm run test-cov - -after_script: - - npm install coveralls - - nyc report --reporter=text-lcov | coveralls diff --git a/lib/generator.js b/lib/generator.js index 6ec9415..1519d02 100644 --- a/lib/generator.js +++ b/lib/generator.js @@ -1,13 +1,12 @@ 'use strict'; const pagination = require('hexo-pagination'); -const { sort } = require('timsort'); module.exports = function(locals) { const config = this.config; const posts = locals.posts.sort(config.index_generator.order_by); - sort(posts.data, (a, b) => (b.sticky || 0) - (a.sticky || 0)); + posts.data.sort((a, b) => (b.sticky || 0) - (a.sticky || 0)); const paginationDir = config.pagination_dir || 'page'; const path = config.index_generator.path || ''; diff --git a/package.json b/package.json index 62a2ac8..f2cb353 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "scripts": { "eslint": "eslint .", "test": "mocha test/index.js", - "test-cov": "nyc npm run test" + "test-cov": "nyc --reporter=lcovonly npm run test" }, "directories": { "lib": "./lib" @@ -16,7 +16,7 @@ "lib/" ], "engines": { - "node": ">=10.13.0" + "node": ">=12.9.0" }, "repository": "hexojs/hexo-generator-index", "homepage": "http://hexo.io/", @@ -37,7 +37,6 @@ "nyc": "^15.0.0" }, "dependencies": { - "hexo-pagination": "1.0.0", - "timsort": "^0.3.0" + "hexo-pagination": "1.0.0" } }