Skip to content
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
9 changes: 9 additions & 0 deletions src/actor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2190,11 +2190,20 @@ export class Actor<Data extends Dictionary = Dictionary> {

/**
* Returns `true` when code is running on Apify platform and `false` otherwise (for example locally).
*
* @deprecated Use {@link isRunningOnApify} instead.
*/
static isAtHome(): boolean {
return Actor.getDefaultInstance().isAtHome();
}

/**
* Returns `true` when code is running on the Apify platform and `false` otherwise (for example locally).
*/
static isRunningOnApify(): boolean {
return Actor.getDefaultInstance().isAtHome();
}

/** Default {@apilink ApifyClient} instance. */
static get apifyClient(): ApifyClient {
return Actor.getDefaultInstance().apifyClient;
Expand Down
5 changes: 4 additions & 1 deletion test/apify/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ import semver from 'semver';
import { APIFY_ENV_VARS } from '@apify/consts';
import log from '@apify/log';

describe('Actor.isAtHome()', () => {
describe('Actor platform detection', () => {
test('works', () => {
expect(Actor.isAtHome()).toBe(false);
expect(Actor.isRunningOnApify()).toBe(false);
process.env[APIFY_ENV_VARS.IS_AT_HOME] = '1';
expect(Actor.isAtHome()).toBe(true);
expect(Actor.isRunningOnApify()).toBe(true);
delete process.env[APIFY_ENV_VARS.IS_AT_HOME];
expect(Actor.isAtHome()).toBe(false);
expect(Actor.isRunningOnApify()).toBe(false);
});
});

Expand Down
Loading