Skip to content

Commit ac8458c

Browse files
cimaMartin ŠimekAnatoly Bolshakov
authored
#667 Error setting resourceFile: "Maximum call stack size exceeded" (#773)
* #667 Error setting resourceFile: "Maximum call stack size exceeded" + Preventing the infinite recustion by not translating warning about missing translation. * Wrong variable in warning output. - Getting rid of unnecessary escaping backslash * Bumping package version * Missing Localization test using mockery The missing file lib.json is simulated via resporting nonexistent file via mockery. Co-authored-by: Martin Šimek <[email protected]> Co-authored-by: Anatoly Bolshakov <[email protected]>
1 parent ba1f94b commit ac8458c

File tree

4 files changed

+33
-4
lines changed

4 files changed

+33
-4
lines changed

node/internal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,10 @@ export function _loc(key: string, ...param: any[]): string {
200200
}
201201
else {
202202
if (Object.keys(_resourceFiles).length <= 0) {
203-
_warning(_loc('LIB_ResourceFileNotSet', key));
203+
_warning(`Resource file haven't been set, can't find loc string for key: ${key}`);
204204
}
205205
else {
206-
_warning(_loc('LIB_LocStringNotFound', key));
206+
_warning(`Can't find loc string for key: ${key}`);
207207
}
208208

209209
locString = key;

node/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "azure-pipelines-task-lib",
3-
"version": "3.1.9",
3+
"version": "3.1.10",
44
"description": "Azure Pipelines Task SDK",
55
"main": "./task.js",
66
"typings": "./task.d.ts",

node/test/internalhelpertests.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as path from 'path';
77
import * as testutil from './testutil';
88
import * as tl from '../_build/task';
99
import * as im from '../_build/internal';
10+
import * as mockery from 'mockery'
1011

1112
describe('Internal Path Helper Tests', function () {
1213

@@ -401,4 +402,32 @@ describe('Internal Path Helper Tests', function () {
401402

402403
done();
403404
});
405+
406+
it('ReportMissingStrings', (done: MochaDone) => {
407+
408+
mockery.registerAllowable('../_build/internal')
409+
const fsMock = {
410+
statSync: function (path) { return null; }
411+
};
412+
mockery.registerMock('fs', fsMock);
413+
mockery.enable({ useCleanCache: true })
414+
415+
const local_im = require('../_build/internal');
416+
417+
try{
418+
const localizedMessage : string = local_im._loc("gizmo", "whatever", "music");
419+
assert.strictEqual(localizedMessage, "gizmo whatever music");
420+
421+
}finally{
422+
mockery.disable();
423+
mockery.deregisterAll();
424+
}
425+
done();
426+
});
427+
428+
it('ReportMissingLocalization', (done: MochaDone) => {
429+
const localizedMessage : string = im._loc("gizmo", "whatever", "music");
430+
assert.strictEqual(localizedMessage, "gizmo whatever music");
431+
done();
432+
});
404433
});

0 commit comments

Comments
 (0)