Skip to content

Commit

Permalink
build: tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Mar 20, 2021
1 parent 0b64e8f commit 2d9c987
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 29 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: test
on: [push, pull_request]
env:
CI: true
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '15'
- name: Install
run: npm install
- name: Test
run: npm test
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
unsafe-perm=true
save-prefix=~
shrinkwrap=false
save=false
5 changes: 0 additions & 5 deletions .travis.yml

This file was deleted.

9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ const microlinkFunction = require('@microlink/function')

const fn = microlinkFunction(({ page }) => page.title())

const result = await fn('https://google.com')
fn('https://google.com').then(result => console.log(result))

console.log(result)
// {
// isFulfilled: true,
// isRejected: false,
Expand All @@ -36,9 +35,8 @@ const microlinkFunction = require('@microlink/function')

const fn = microlinkFunction(({ page }) => response.status())

const result = await fn('https://google.com')
fn('https://google.com').then(result => console.log(result))

console.log(result)
// {
// isFulfilled: true,
// isRejected: false,
Expand All @@ -53,9 +51,8 @@ const microlinkFunction = require('@microlink/function')

const fn = microlinkFunction(({ query }) => query.greetings)

const result = await fn('https://google.com', { greetings: 'hello world' })
fn('https://google.com', { greetings: 'hello world' }).then(result => console.log(result))

console.log(result)
// {
// isFulfilled: true,
// isRejected: false,
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@
"serverless"
],
"dependencies": {
"@microlink/mql": "~0.8.2"
"@microlink/mql": "~0.9.1"
},
"devDependencies": {
"@commitlint/cli": "latest",
"@commitlint/config-conventional": "latest",
"ava": "latest",
"conventional-github-releaser": "latest",
"coveralls": "latest",
"finepack": "latest",
"git-authors-cli": "latest",
"git-dirty": "latest",
"husky": "latest",
"lint-staged": "latest",
"npm-check-updates": "latest",
"nyc": "latest",
"pinst": "latest",
"prettier-standard": "latest",
"standard": "latest",
"standard-markdown": "latest",
Expand All @@ -56,10 +56,11 @@
"scripts": {
"clean": "rm -rf node_modules",
"contributors": "(git-authors-cli && finepack && git add package.json && git commit -m 'build: contributors' --no-verify) || true",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"lint": "standard-markdown README.md && standard",
"postinstall": "husky install",
"postpublish": "pinst --enable",
"postrelease": "npm run release:tags && npm run release:github && npm publish",
"prepublishOnly": "pinst --disable",
"prerelease": "git-dirty && npm run update:check && npm test && npm run contributors",
"pretest": "npm run lint",
"release": "git-authors-cli finepack && git add package.json && standard-version -a",
Expand Down
9 changes: 3 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

const mql = require('@microlink/mql')

module.exports = (code, mqlOpts, gotOpts) => async (url, opts) => {
const { data } = await mql(
module.exports = (code, mqlOpts, gotOpts) => (url, opts) =>
mql(
url,
{
function: code.toString(),
Expand All @@ -12,7 +12,4 @@ module.exports = (code, mqlOpts, gotOpts) => async (url, opts) => {
...opts
},
gotOpts
)

return data.function
}
).then(({ data }) => data.function)
12 changes: 3 additions & 9 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ const microlinkFunction = require('..')
test('interact with the page', async t => {
const getTitle = ({ page }) => page.title()

const myFn = microlinkFunction(getTitle, {
endpoint: 'https://next.microlink.io'
})
const myFn = microlinkFunction(getTitle)

const result = await myFn('https://google.com')

Expand All @@ -23,9 +21,7 @@ test('interact with the page', async t => {
test('interact with the response', async t => {
const getTitle = ({ response }) => response.status()

const myFn = microlinkFunction(getTitle, {
endpoint: 'https://next.microlink.io'
})
const myFn = microlinkFunction(getTitle)

const result = await myFn('https://google.com')

Expand All @@ -39,9 +35,7 @@ test('interact with the response', async t => {
test('interact with the query', async t => {
const getTitle = ({ query }) => query.greetings

const myFn = microlinkFunction(getTitle, {
endpoint: 'https://next.microlink.io'
})
const myFn = microlinkFunction(getTitle)

const result = await myFn('https://google.com', { greetings: 'hello world' })

Expand Down

0 comments on commit 2d9c987

Please sign in to comment.