Skip to content
Merged
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
35 changes: 35 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Test Suite

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

permissions:
contents: read

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

strategy:
fail-fast: false
matrix:
node-version: [ 20.x, 22.x, 24.x ]
os: [ ubuntu-latest, macos-latest ]

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Use Node.js ${{ matrix.node-version }} on ${{ matrix.os }}
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- run: npm ci --ignore-scripts

- run: npm test

- run: npm run test-e2e
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ data/cores/*
.vscode/*
*.tgz
dist/
.tap/

.idea/
27 changes: 27 additions & 0 deletions e2e/minify.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { test } from 'tap';
import { execSync } from 'child_process';
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const rootPath = path.resolve(__dirname, "../");

test('npm run minify creates emulator.min.js and emulator.min.css', (t) => {
// Run the npm script
execSync('npm run minify', { cwd: rootPath });

const outJs = path.join(rootPath, 'data/emulator.min.js');
const outCss = path.join(rootPath, 'data/emulator.min.css');

t.ok(fs.existsSync(outJs), 'output JS exists');
t.ok(fs.existsSync(outCss), 'output CSS exists');

const jsStat = fs.statSync(outJs);
const cssStat = fs.statSync(outCss);

t.ok(jsStat.size > 0, 'output JS has content');
t.ok(cssStat.size > 0, 'output CSS has content');
t.end();
});
26 changes: 18 additions & 8 deletions minify/minify.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,41 @@ const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const rootPath = path.resolve(__dirname, "../");

async function doMinify() {
export async function doMinify(inputJs, outputJs, inputCss, outputCss) {
await minify({
compressor: terser,
input: path.join(rootPath, "data/src/*.js"),
output: path.join(rootPath, "data/emulator.min.js"),
input: inputJs,
output: outputJs,
})
.catch(function (err) {
console.error(err);
throw err;
})
.then(function() {
console.log("Minified JS");
});
await minify({
compressor: cleanCSS,
input: path.join(rootPath, "data/emulator.css"),
output: path.join(rootPath, "data/emulator.min.css"),
input: inputCss,
output: outputCss,
})
.catch(function (err) {
console.error(err);
throw err;
})
.then(function() {
console.log("Minified CSS");
});
}

console.log("Minifying");
await doMinify();
console.log("Minifying Done!");
// If run directly
if (process.argv[1] && fileURLToPath(import.meta.url) === path.resolve(process.argv[1])) {
console.log("Minifying");
await doMinify(
path.join(rootPath, "data/src/*.js"),
path.join(rootPath, "data/emulator.min.js"),
path.join(rootPath, "data/emulator.css"),
path.join(rootPath, "data/emulator.min.css")
);
console.log("Minifying Done!");
}
Loading
Loading