Skip to content

Commit

Permalink
microsoft#667 Error setting resourceFile: "Maximum call stack size e…
Browse files Browse the repository at this point in the history
…xceeded" (microsoft#773)

* microsoft#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 <martin.simek@digiteqautomotive.com>
Co-authored-by: Anatoly Bolshakov <anatoly.bolshakov@akvelon.com>
  • Loading branch information
3 people authored Oct 6, 2021
1 parent ba1f94b commit ac8458c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
4 changes: 2 additions & 2 deletions node/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,10 @@ export function _loc(key: string, ...param: any[]): string {
}
else {
if (Object.keys(_resourceFiles).length <= 0) {
_warning(_loc('LIB_ResourceFileNotSet', key));
_warning(`Resource file haven't been set, can't find loc string for key: ${key}`);
}
else {
_warning(_loc('LIB_LocStringNotFound', key));
_warning(`Can't find loc string for key: ${key}`);
}

locString = key;
Expand Down
2 changes: 1 addition & 1 deletion node/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "azure-pipelines-task-lib",
"version": "3.1.9",
"version": "3.1.10",
"description": "Azure Pipelines Task SDK",
"main": "./task.js",
"typings": "./task.d.ts",
Expand Down
29 changes: 29 additions & 0 deletions node/test/internalhelpertests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as path from 'path';
import * as testutil from './testutil';
import * as tl from '../_build/task';
import * as im from '../_build/internal';
import * as mockery from 'mockery'

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

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

done();
});

it('ReportMissingStrings', (done: MochaDone) => {

mockery.registerAllowable('../_build/internal')
const fsMock = {
statSync: function (path) { return null; }
};
mockery.registerMock('fs', fsMock);
mockery.enable({ useCleanCache: true })

const local_im = require('../_build/internal');

try{
const localizedMessage : string = local_im._loc("gizmo", "whatever", "music");
assert.strictEqual(localizedMessage, "gizmo whatever music");

}finally{
mockery.disable();
mockery.deregisterAll();
}
done();
});

it('ReportMissingLocalization', (done: MochaDone) => {
const localizedMessage : string = im._loc("gizmo", "whatever", "music");
assert.strictEqual(localizedMessage, "gizmo whatever music");
done();
});
});

0 comments on commit ac8458c

Please sign in to comment.