Skip to content

Commit

Permalink
add run-tests.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
h.u.g.u.rp committed Jun 29, 2023
1 parent 6d68767 commit 2cbd674
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/run-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Run tests
on: push
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/setup-node@v3
- run: npm install
- run: npm run test
8 changes: 5 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* if we are in node, polyfill what's missing to work */
if (typeof window === "undefined") {
const isBrowser = typeof window !== "undefined";
const isNode = typeof process !== "undefined";
if (!isBrowser && isNode) {
globalThis.window = {};
window.location = new URL("i4k-find://");
}
Expand Down Expand Up @@ -280,7 +282,7 @@ const App = {
/* when in browser */
if (typeof window.location === "function") {
window.location.replace(url);
} else if (process && process.env.BROWSER) {
} else if (isNode && process.env.BROWSER) {
// noop
}
return url;
Expand Down Expand Up @@ -376,7 +378,7 @@ const App = {
};

/* handle node input if any */
if (process && process.argv.length > 2) {
if (!isBrowser && isNode && process.argv.length > 2) {
const userArg = process.argv.slice(2).join(" ");
App.find(userArg);
}
Expand Down

0 comments on commit 2cbd674

Please sign in to comment.