Skip to content

added is_testing env variable so that requires work better with auto bundlers like vite #180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
40 changes: 28 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,37 @@ const { platform, arch } = process
/** @typedef {typeof import('./client.d')} Client */
/** @type {Client} */
let nativeBinding = undefined

if (platform === 'win32' && arch === 'x64') {
nativeBinding = require('./dist/win64/steamworksjs.win32-x64-msvc.node')
} else if (platform === 'linux' && arch === 'x64') {
nativeBinding = require('./dist/linux64/steamworksjs.linux-x64-gnu.node')
} else if (platform === 'darwin') {
if (arch === 'x64') {
nativeBinding = require('./dist/osx/steamworksjs.darwin-x64.node')
} else if (arch === 'arm64') {
nativeBinding = require('./dist/osx/steamworksjs.darwin-arm64.node')
if(process.env.IS_TESTING){
if (platform === 'win32' && arch === 'x64') {
nativeBinding = require('./dist/win64/steamworksjs.win32-x64-msvc.node')
} else if (platform === 'linux' && arch === 'x64') {
nativeBinding = require('./dist/linux64/steamworksjs.linux-x64-gnu.node')
} else if (platform === 'darwin') {
if (arch === 'x64') {
nativeBinding = require('./dist/osx/steamworksjs.darwin-x64.node')
} else if (arch === 'arm64') {
nativeBinding = require('./dist/osx/steamworksjs.darwin-arm64.node')
}
} else {
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
}
} else {
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
if (platform === 'win32' && arch === 'x64') {
nativeBinding = require('steamworks.js/dist/win64/steamworksjs.win32-x64-msvc.node')
} else if (platform === 'linux' && arch === 'x64') {
nativeBinding = require('steamworks.js/dist/linux64/steamworksjs.linux-x64-gnu.node')
} else if (platform === 'darwin') {
if (arch === 'x64') {
nativeBinding = require('steamworks.js/dist/osx/steamworksjs.darwin-x64.node')
} else if (arch === 'arm64') {
nativeBinding = require('steamworks.js/dist/osx/steamworksjs.darwin-arm64.node')
}
} else {
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
}
}


let runCallbacksInterval = undefined

/**
Expand Down Expand Up @@ -74,4 +90,4 @@ module.exports.electronEnableSteamOverlay = (disableEachFrameInvalidation) => {
}

const SteamCallback = nativeBinding.callback.SteamCallback
module.exports.SteamCallback = SteamCallback
module.exports.SteamCallback = SteamCallback
2 changes: 2 additions & 0 deletions test/auth.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
process.env.IS_TESTING = true

const { init } = require('../index.js')

const client = init(480)
Expand Down
2 changes: 2 additions & 0 deletions test/callback.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
process.env.IS_TESTING = true

const { init, SteamCallback } = require('../index.js')

const client = init(480);
Expand Down
2 changes: 2 additions & 0 deletions test/input.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
process.env.IS_TESTING = true

const { init } = require('../index.js')

const client = init(1694450)
Expand Down
2 changes: 2 additions & 0 deletions test/matchmaking.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
process.env.IS_TESTING = true

const { init, SteamCallback } = require('../index.js')

const client = init(480)
Expand Down
3 changes: 3 additions & 0 deletions test/networking.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
const rl = require('readline');

process.env.IS_TESTING = true

const { init, SteamCallback } = require('../index.js')

const client = init(480)
Expand Down
2 changes: 2 additions & 0 deletions test/overlay.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
process.env.IS_TESTING = true

const { init } = require('../index.js')

const client = init(480)
Expand Down
2 changes: 2 additions & 0 deletions test/user.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
process.env.IS_TESTING = true

const { init } = require('../index.js')

const client = init(480)
Expand Down
2 changes: 2 additions & 0 deletions test/workshop.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
process.env.IS_TESTING = true

const { init } = require('../index.js');

(async () => {
Expand Down