Skip to content

Commit 4ceb39f

Browse files
committed
Add a public method to know whether the runtime is configured
1 parent a33bd02 commit 4ceb39f

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,10 @@ class Encore {
11571157
return this;
11581158
}
11591159

1160+
isRuntimeConfigured() {
1161+
return runtimeConfig !== null;
1162+
}
1163+
11601164
/**
11611165
* Clear the runtime environment.
11621166
*
@@ -1213,6 +1217,7 @@ const EncoreProxy = new Proxy(new Encore(), {
12131217
const safeMethods = [
12141218
'configureRuntimeEnvironment',
12151219
'clearRuntimeEnvironment',
1220+
'isRuntimeConfigured',
12161221
];
12171222

12181223
if (!webpackConfig && (safeMethods.indexOf(prop) === -1)) {

test/index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,22 @@ describe('Public API', () => {
414414

415415
});
416416

417+
describe('isRuntimeConfigured', () => {
418+
419+
it('should return true if the runtime environment has been configured', () => {
420+
const returnedValue = api.isRuntimeConfigured();
421+
expect(returnedValue).to.be.true;
422+
});
423+
424+
it('should return false if the runtime environment has not been configured', () => {
425+
api.clearRuntimeEnvironment();
426+
427+
const returnedValue = api.isRuntimeConfigured();
428+
expect(returnedValue).to.be.false;
429+
});
430+
431+
});
432+
417433
describe('Runtime environment proxy', () => {
418434
beforeEach(() => {
419435
api.clearRuntimeEnvironment();

0 commit comments

Comments
 (0)