vscode-nls
Advanced tools
Comparing version 3.2.5 to 4.0.0
@@ -16,4 +16,4 @@ export declare enum MessageFormat { | ||
export interface LocalizeFunc { | ||
(info: LocalizeInfo, message: string, ...args: any[]): string; | ||
(key: string, message: string, ...args: any[]): string; | ||
(info: LocalizeInfo, message: string, ...args: (string | number | boolean | undefined | null)[]): string; | ||
(key: string, message: string, ...args: (string | number | boolean | undefined | null)[]): string; | ||
} | ||
@@ -20,0 +20,0 @@ export interface LoadFunc { |
@@ -22,2 +22,5 @@ /* -------------------------------------------------------------------------------------------- | ||
} | ||
function readJsonFileSync(filename) { | ||
return JSON.parse(fs.readFileSync(filename, 'utf8')); | ||
} | ||
var MessageFormat; | ||
@@ -61,3 +64,3 @@ (function (MessageFormat) { | ||
try { | ||
options.translationsConfig = require(options.translationsConfigFile); | ||
options.translationsConfig = readJsonFileSync(options.translationsConfigFile); | ||
} | ||
@@ -99,3 +102,11 @@ catch (error) { | ||
var index = rest[0]; | ||
return typeof args[index] !== 'undefined' ? args[index] : match; | ||
var arg = args[index]; | ||
var replaced = match; | ||
if (typeof arg === 'string') { | ||
replaced = arg; | ||
} | ||
else if (typeof arg === 'number' || typeof arg === 'boolean' || arg === void 0 || arg === null) { | ||
replaced = String(arg); | ||
} | ||
return replaced; | ||
}); | ||
@@ -218,3 +229,3 @@ } | ||
function createDefaultNlsBundle(folder) { | ||
var metaData = require(path.join(folder, 'nls.metadata.json')); | ||
var metaData = readJsonFileSync(path.join(folder, 'nls.metadata.json')); | ||
var result = Object.create(null); | ||
@@ -232,4 +243,4 @@ for (var module_1 in metaData) { | ||
} | ||
var languagePack = require(languagePackLocation).contents; | ||
var metaData = require(path.join(metaDataPath, 'nls.metadata.json')); | ||
var languagePack = readJsonFileSync(languagePackLocation).contents; | ||
var metaData = readJsonFileSync(path.join(metaDataPath, 'nls.metadata.json')); | ||
var result = Object.create(null); | ||
@@ -343,3 +354,3 @@ for (var module_2 in metaData) { | ||
try { | ||
return require(candidate); | ||
return readJsonFileSync(candidate); | ||
} | ||
@@ -422,3 +433,3 @@ catch (err) { | ||
try { | ||
var json = require(resolveLanguage(file)); | ||
var json = readJsonFileSync(resolveLanguage(file)); | ||
if (Array.isArray(json)) { | ||
@@ -425,0 +436,0 @@ return createScopedLocalizeFunction(json); |
{ | ||
"name": "vscode-nls", | ||
"version": "3.2.5", | ||
"version": "4.0.0", | ||
"description": "NPM module to externalize and localize VSCode extensions", | ||
@@ -5,0 +5,0 @@ "author": "Microsoft Corporation", |
@@ -41,2 +41,7 @@ # vscode-nls | ||
### 4.0.0 | ||
* make vscode-nls webpack friendly (removal of require calls) | ||
* narrow type for var args in `localize` function to `string | number | boolean | null | undefined` | ||
### 3.0.0: | ||
@@ -43,0 +48,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
23777
493
61
3