Skip to content
Draft
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
26 changes: 26 additions & 0 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Node.js CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [windows-latest] # ubuntu-latest, mac-latest

steps:
- uses: actions/checkout@v3

- name: Use Node LTS
uses: actions/setup-node@v3

with:
node-version: lts/*
- run: npm ci
- run: npm test
1 change: 1 addition & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ console.log(`\nRunning ${pc.green(`${pc.bold('mkcert-cli')}`)} (${pkgVersion})\n
(dryRun || verbose) &&
console.log(`${pc.bold('With options:')}
- ${pc.blue('cwd')}: ${pc.yellow(cwd)}
- ${pc.blue('dataDir')}: ${pc.yellow(DATA_DIR)}
- ${pc.blue('outDir')}: ${pc.yellow(outDir)}
- ${pc.blue('hosts')}: ${JSON.stringify(hosts)}
- ${pc.blue('cert')}: ${certFile}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"src/"
],
"scripts": {
"test": "npx -y rome check . && vitest run",
"test": "npx -y rome check . && vitest run --reporter verbose",
"tdd": "vitest",
"fix": "npx -y rome format . --write",
"publish:dev": "npx -y np prerelease --tag=next --any-branch --no-release-draft",
Expand Down
32 changes: 26 additions & 6 deletions test/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,52 @@ import pkgJson from '../package.json' assert { type: 'json' };
import { dirname, join, resolve } from 'path';
import { homedir } from 'os';

describe('semverGreaterThan', () => {
const cliPath = resolve(join(dirname(new URL(import.meta.url).pathname), '../cli.js'));

describe('--dryRun', () => {
it('more of a debug print session for CI', async () => {

const cmd = `node ${cliPath} --dryRun`;
console.log('PLEASE READ THIS', {
cwd: process.cwd(),
cliPath,
importURL: import.meta.url,
filePathURL: new URL('..cli.js', import.meta.url).toString(),
filePathResolve: resolve('../cli.js'),
resolveJoinDirname: resolve(join(dirname(import.meta.url), '../cli.js')),
});
const { stdout } = await exec(cmd, { cwd: homedir(), env: { ...process.env } });
console.log(`
${stdout}
`);
});
});

describe.skip('semverGreaterThan', () => {
it('returns expected bool', () => {
assert.ok(semverGreaterThan('v1.4.4', 'v.1.4.3'));
assert.notOk(semverGreaterThan('v1.4.3', 'v.1.4.4'));
assert.notOk(semverGreaterThan('v1.4.4', 'v1.4.4'));
});
});

describe('pkgJson', () => {
describe.skip('pkgJson', () => {
it('matches asserted import value', () => {
assert.equal(pkgVersion, `v${pkgJson.version}`);
});

it('cli.js --version, also works from random directory', async () => {
const cliPathAbs = getAbsolutePath('../cli.js', import.meta.url);
const cmd = `node ${cliPathAbs} --version`;
const cmd = `node ${cliPath} --version`;
const { stdout } = await exec(cmd, { cwd: homedir(), env: { ...process.env } });
assert.equal(pkgVersion, `${stdout.trim()}`);
});
});

const testCertFolder = 'tstCertFolder';
const cmd = `node ${join(dirname(import.meta.url), '../cli.js').replace(/^file:/, '')}`;
const cmd = `node ${cliPath}`;
const rmTestDir = async () => await exec(`rm -rf ${testCertFolder}`, {});

describe('cli', () => {
describe.skip('cli', () => {
beforeEach(async () => {
await rmTestDir();
});
Expand Down