Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add github CI pipeline #93

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CI

on:
push:
branches:
- master
pull_request:
branches:
- '**'

jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Lint code
run: npm run lint

- name: Test code
run: npm run test

- name: Test dts
run: npm run test:dts

- name: Build
run: npm run build

- name: Test code
run: npm run test
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Release
on: workflow_dispatch
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Lint code
run: npm run lint

- name: Test code
run: npm run test

- name: Build
run: npm run build

- name: Test code
run: npm run test

- name: Test dts
run: npm run test:dts

- name: Semantic Release
uses: cycjimmy/semantic-release-action@v2
with:
branches: |
[
'master'
]
env:
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
node_modules
coverage
package-lock.json
.idea
.vscode
26 changes: 0 additions & 26 deletions .travis.yml

This file was deleted.

18 changes: 0 additions & 18 deletions .zuul.yml

This file was deleted.

70 changes: 0 additions & 70 deletions Makefile

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
[jekyll]: https://github.com/mojombo/jekyll
[coverage-img]: https://img.shields.io/coveralls/jxson/front-matter.svg
[coverage-url]: https://coveralls.io/r/jxson/front-matter?branch=master
[build-img]: https://img.shields.io/travis/jxson/front-matter/master.svg
[build-url]: http://travis-ci.org/jxson/front-matter
[build-img]: https://github.com/jxson/front-matter/workflows/CI/badge.svg
[build-url]: https://github.com/jxson/front-matter/actions/workflows/ci.yml?query=branch%3Amaster
[npm-img]: https://img.shields.io/npm/dm/front-matter.svg
[npm-url]: https://npmjs.org/package/front-matter
[github-img]: https://img.shields.io/github/stars/jxson/front-matter.svg?style=social&label=Star
Expand Down
36 changes: 18 additions & 18 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var parser = require('js-yaml')
var optionalByteOrderMark = '\\ufeff?'
var platform = typeof process !== 'undefined' ? process.platform : ''
var pattern = '^(' +
const parser = require('js-yaml')
const optionalByteOrderMark = '\\ufeff?'
const platform = typeof process !== 'undefined' ? process.platform : ''
const pattern = '^(' +
optionalByteOrderMark +
'(= yaml =|---)' +
'$([\\s\\S]*?)' +
Expand All @@ -11,17 +11,17 @@ var pattern = '^(' +
'(?:\\n)?)'
// NOTE: If this pattern uses the 'g' flag the `regex` variable definition will
// need to be moved down into the functions that use it.
var regex = new RegExp(pattern, 'm')
const regex = new RegExp(pattern, 'm')

module.exports = extractor
module.exports.test = test

function extractor (string, options) {
string = string || ''
var defaultOptions = { allowUnsafe: false }
const defaultOptions = { allowUnsafe: false }
options = options instanceof Object ? { ...defaultOptions, ...options } : defaultOptions
options.allowUnsafe = Boolean(options.allowUnsafe)
var lines = string.split(/(\r?\n)/)
const lines = string.split(/(\r?\n)/)
if (lines[0] && /= yaml =|---/.test(lines[0])) {
return parse(string, options.allowUnsafe)
} else {
Expand All @@ -34,9 +34,9 @@ function extractor (string, options) {
}

function computeLocation (match, body) {
var line = 1
var pos = body.indexOf('\n')
var offset = match.index + match[0].length
let line = 1
let pos = body.indexOf('\n')
const offset = match.index + match[0].length

while (pos !== -1) {
if (pos >= offset) {
Expand All @@ -50,7 +50,7 @@ function computeLocation (match, body) {
}

function parse (string, allowUnsafe) {
var match = regex.exec(string)
const match = regex.exec(string)
if (!match) {
return {
attributes: {},
Expand All @@ -59,15 +59,15 @@ function parse (string, allowUnsafe) {
}
}

var loader = allowUnsafe ? parser.load : parser.safeLoad
var yaml = match[match.length - 1].replace(/^\s+|\s+$/g, '')
var attributes = loader(yaml) || {}
var body = string.replace(match[0], '')
var line = computeLocation(match, string)
const loader = allowUnsafe ? parser.load : parser.safeLoad
const yaml = match[match.length - 1].replace(/^\s+|\s+$/g, '')
const attributes = loader(yaml) || {}
const body = string.replace(match[0], '')
const line = computeLocation(match, string)

return {
attributes: attributes,
body: body,
attributes,
body,
bodyBegin: line,
frontmatter: yaml
}
Expand Down
15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,18 @@
},
"main": "index.js",
"scripts": {
"test": "make test && check-dts"
"lint": "standard",
"lint-fix": "standard --fix",
"test": "tape test/*.js",
"test:dts": "check-dts"
},
"dependencies": {
"js-yaml": "^3.13.1"
},
"devDependencies": {
"brfs": "^2.0.2",
"check-dts": "^0.3.0",
"coveralls": "^3.0.9",
"istanbul": "^0.4.5",
"standard": "^14.3.4",
"tape": "^4.4.0",
"zuul": "^3.12.0"
"check-dts": "^0.7.2",
"standard": "^17.1.0",
"tape": "^5.6.6"
},
"files": [
"index.d.ts"
Expand Down
Loading