Skip to content

Commit

Permalink
Run node with flags for jest, build for mac
Browse files Browse the repository at this point in the history
  • Loading branch information
benschwarz committed Aug 24, 2022
1 parent 10a82ec commit ce41320
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ jobs:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
node-version: [14.x, 15.x, 16.x, 17.x, 18.x]
os: [ubuntu-latest, windows-latest]

os: [ubuntu-latest, windows-latest, macos-latest]
timeout-minutes: 3
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
Expand Down
1 change: 1 addition & 0 deletions .jest-setup.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
process.env.CALIBRE_API_TOKEN = 'test'
process.env.CALIBRE_HOST = 'http://localhost:5678'
process.env.TZ = 'Etc/GMT'
6 changes: 5 additions & 1 deletion __tests__/cli/request.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ describe('request', () => {

test('returns response', async () => {
const slug = 'calibre'
// eslint-disable-next-line no-useless-escape
const query = 'query GetSite($slug: String!) {organisation{site(slug: $slug){slug}}}'
const args = `request --slug=${slug} --query="${query}"`

const out = await runCLI({
args: `request --query='query GetSite($slug: String!) {organisation{site(slug: $slug){slug}}}' --slug=${slug}`
args
})
expect(out).toMatchSnapshot()
})
Expand Down
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export default {
testMatch: ['**/__tests__/**/*.test.js?(x)'],
testEnvironment: 'node',
setupFiles: ['./.jest-setup.js'],
testTimeout: 5000,
modulePathIgnorePatterns: ['./dist'],
// chalk appears to inline it's dependencies, but jest requires module resolution help
// https://github.com/chalk/chalk/blob/main/package.json#L11-L17
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
"prettier": "2.7.1"
},
"scripts": {
"ci": "NODE_OPTIONS='--no-warnings --experimental-vm-modules' CI=true TZ=Etc/GMT jest --coverage --runInBand --no-colors",
"test": "NODE_OPTIONS='--no-warnings --experimental-vm-modules' TZ=Etc/GMT jest",
"ci": "node --no-warnings --experimental-vm-modules node_modules/jest/bin/jest.js --coverage --runInBand --no-colors --verbose=false",
"test": "node --no-warnings --experimental-vm-modules node_modules/jest/bin/jest.js --verbose=false",
"lint": "eslint .",
"clean": "rm -rf dist/",
"build": "npm run clean && esbuild index.js --bundle --platform=node --outfile=dist/index.cjs",
Expand Down
3 changes: 2 additions & 1 deletion src/cli.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env NODE_NO_WARNINGS=1 node
#!/usr/bin/env node

import fs from 'fs'

Expand All @@ -17,6 +17,7 @@ import commands from './cli-commands.js'

yargs(hideBin(process.argv))
.usage(`${chalk.bold('♠ calibre')} subcommand [options]`)
.scriptName('calibre')
.commands(commands)
.demandCommand()
.recommendCommands()
Expand Down

0 comments on commit ce41320

Please sign in to comment.