Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 73e316e

Browse files
bnoordhuisitaloacasas
authored andcommittedFeb 22, 2017
src: make --icu-data-dir= switch testable
Move some code around so we can properly test whether the switch actually does anything. PR-URL: #11255 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
1 parent 96a6d64 commit 73e316e

File tree

6 files changed

+15
-21
lines changed

6 files changed

+15
-21
lines changed
 

‎lib/internal/process.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function setupConfig(_source) {
122122
const oldV8BreakIterator = Intl.v8BreakIterator;
123123
const des = Object.getOwnPropertyDescriptor(Intl, 'v8BreakIterator');
124124
des.value = require('internal/util').deprecate(function v8BreakIterator() {
125-
if (processConfig.hasSmallICU && !process.icu_data_dir) {
125+
if (processConfig.hasSmallICU && !processConfig.icuDataDir) {
126126
// Intl.v8BreakIterator() would crash w/ fatal error, so throw instead.
127127
throw new Error('v8BreakIterator: full ICU data not installed. ' +
128128
'See https://github.com/nodejs/node/wiki/Intl');
@@ -131,8 +131,6 @@ function setupConfig(_source) {
131131
}, 'Intl.v8BreakIterator is deprecated and will be removed soon.');
132132
Object.defineProperty(Intl, 'v8BreakIterator', des);
133133
}
134-
// Don’t let icu_data_dir leak through.
135-
delete process.icu_data_dir;
136134
}
137135

138136

‎src/node.cc

+1-12
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ static node_module* modlist_addon;
154154

155155
#if defined(NODE_HAVE_I18N_SUPPORT)
156156
// Path to ICU data (for i18n / Intl)
157-
static std::string icu_data_dir; // NOLINT(runtime/string)
157+
std::string icu_data_dir; // NOLINT(runtime/string)
158158
#endif
159159

160160
// used by C++ modules as well
@@ -3067,17 +3067,6 @@ void SetupProcessObject(Environment* env,
30673067
"ares",
30683068
FIXED_ONE_BYTE_STRING(env->isolate(), ARES_VERSION_STR));
30693069

3070-
#if defined(NODE_HAVE_I18N_SUPPORT) && defined(U_ICU_VERSION)
3071-
// ICU-related versions are now handled on the js side, see bootstrap_node.js
3072-
3073-
if (!icu_data_dir.empty()) {
3074-
// Did the user attempt (via env var or parameter) to set an ICU path?
3075-
READONLY_PROPERTY(process,
3076-
"icu_data_dir",
3077-
OneByteString(env->isolate(), icu_data_dir.c_str()));
3078-
}
3079-
#endif
3080-
30813070
const char node_modules_version[] = NODE_STRINGIFY(NODE_MODULE_VERSION);
30823071
READONLY_PROPERTY(
30833072
versions,

‎src/node_config.cc

+5-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,11 @@ void InitConfig(Local<Object> target,
3838
READONLY_BOOLEAN_PROPERTY("hasSmallICU");
3939
#endif // NODE_HAVE_SMALL_ICU
4040

41-
if (flag_icu_data_dir)
42-
READONLY_BOOLEAN_PROPERTY("usingICUDataDir");
41+
target->DefineOwnProperty(env->context(),
42+
OneByteString(env->isolate(), "icuDataDir"),
43+
OneByteString(env->isolate(), icu_data_dir.data()))
44+
.FromJust();
45+
4346
#endif // NODE_HAVE_I18N_SUPPORT
4447

4548
if (config_preserve_symlinks)

‎src/node_i18n.cc

-3
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ using v8::Object;
7070
using v8::String;
7171
using v8::Value;
7272

73-
bool flag_icu_data_dir = false;
74-
7573
namespace i18n {
7674

7775
const size_t kStorageSize = 1024;
@@ -415,7 +413,6 @@ bool InitializeICUDirectory(const std::string& path) {
415413
#endif // !NODE_HAVE_SMALL_ICU
416414
return (status == U_ZERO_ERROR);
417415
} else {
418-
flag_icu_data_dir = true;
419416
u_setDataDirectory(path.c_str());
420417
return true; // No error.
421418
}

‎src/node_i18n.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace node {
1212

13-
extern bool flag_icu_data_dir;
13+
extern std::string icu_data_dir; // NOLINT(runtime/string)
1414

1515
namespace i18n {
1616

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Flags: --icu-data-dir=test/fixtures/empty/
2+
'use strict';
3+
require('../common');
4+
const assert = require('assert');
5+
6+
// No-op when ICU case mappings are unavailable.
7+
assert.strictEqual('ç'.toLocaleUpperCase('el'), 'ç');

0 commit comments

Comments
 (0)
Failed to load comments.