| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7c2060c commit 10a2ade
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -916,9 +916,14 @@ static ExitCode InitializeNodeWithArgsInternal( | |||
| 916 | 916 | ||
| 917 | 917 | // Initialize ICU. | |
| 918 | 918 | // If icu_data_dir is empty here, it will load the 'minimal' data. | |
| 919 | - if (!i18n::InitializeICUDirectory(per_process::cli_options->icu_data_dir)) { | ||
| 920 | - errors->push_back("could not initialize ICU " | ||
| 921 | - "(check NODE_ICU_DATA or --icu-data-dir parameters)\n"); | ||
| 919 | + std::string icu_error; | ||
| 920 | + if (!i18n::InitializeICUDirectory(per_process::cli_options->icu_data_dir, | ||
| 921 | + &icu_error)) { | ||
| 922 | + errors->push_back(icu_error + | ||
| 923 | + ": Could not initialize ICU. " | ||
| 924 | + "Check the directory specified by NODE_ICU_DATA or " | ||
| 925 | + "--icu-data-dir contains " U_ICUDATA_NAME ".dat and " | ||
| 926 | + "it's readable\n"); | ||
| 922 | 927 | return ExitCode::kInvalidCommandLineArgument; | |
| 923 | 928 | } | |
| 924 | 929 | per_process::metadata.versions.InitializeIntlVersions(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -54,20 +54,21 @@ | |||
| 54 | 54 | #include "util-inl.h" | |
| 55 | 55 | #include "v8.h" | |
| 56 | 56 | ||
| 57 | - #include <unicode/utypes.h> | ||
| 58 | 57 | #include <unicode/putil.h> | |
| 58 | + #include <unicode/timezone.h> | ||
| 59 | 59 | #include <unicode/uchar.h> | |
| 60 | 60 | #include <unicode/uclean.h> | |
| 61 | + #include <unicode/ucnv.h> | ||
| 61 | 62 | #include <unicode/udata.h> | |
| 62 | 63 | #include <unicode/uidna.h> | |
| 63 | - #include <unicode/ucnv.h> | ||
| 64 | - #include <unicode/utf8.h> | ||
| 65 | - #include <unicode/utf16.h> | ||
| 66 | - #include <unicode/timezone.h> | ||
| 67 | 64 | #include <unicode/ulocdata.h> | |
| 65 | + #include <unicode/urename.h> | ||
| 66 | + #include <unicode/ustring.h> | ||
| 67 | + #include <unicode/utf16.h> | ||
| 68 | + #include <unicode/utf8.h> | ||
| 69 | + #include <unicode/utypes.h> | ||
| 68 | 70 | #include <unicode/uvernum.h> | |
| 69 | 71 | #include <unicode/uversion.h> | |
| 70 | - #include <unicode/ustring.h> | ||
| 71 | 72 | ||
| 72 | 73 | #ifdef NODE_HAVE_SMALL_ICU | |
| 73 | 74 | /* if this is defined, we have a 'secondary' entry point. | |
@@ -569,8 +570,7 @@ ConverterObject::ConverterObject( | |||
| 569 | 570 | } | |
| 570 | 571 | } | |
| 571 | 572 | ||
| 572 | - | ||
| 573 | - bool InitializeICUDirectory(const std::string& path) { | ||
| 573 | + bool InitializeICUDirectory(const std::string& path, std::string* error) { | ||
| 574 | 574 | UErrorCode status = U_ZERO_ERROR; | |
| 575 | 575 | if (path.empty()) { | |
| 576 | 576 | #ifdef NODE_HAVE_SMALL_ICU | |
@@ -583,7 +583,12 @@ bool InitializeICUDirectory(const std::string& path) { | |||
| 583 | 583 | u_setDataDirectory(path.c_str()); | |
| 584 | 584 | u_init(&status); | |
| 585 | 585 | } | |
| 586 | - return status == U_ZERO_ERROR; | ||
| 586 | + if (status == U_ZERO_ERROR) { | ||
| 587 | + return true; | ||
| 588 | + } | ||
| 589 | + | ||
| 590 | + *error = u_errorName(status); | ||
| 591 | + return false; | ||
| 587 | 592 | } | |
| 588 | 593 | ||
| 589 | 594 | void SetDefaultTimeZone(const char* tzid) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,7 +38,7 @@ | |||
| 38 | 38 | namespace node { | |
| 39 | 39 | namespace i18n { | |
| 40 | 40 | ||
| 41 | - bool InitializeICUDirectory(const std::string& path); | ||
| 41 | + bool InitializeICUDirectory(const std::string& path, std::string* error); | ||
| 42 | 42 | ||
| 43 | 43 | void SetDefaultTimeZone(const char* tzid); | |
| 44 | 44 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,27 +1,33 @@ | |||
| 1 | 1 | // Flags: --expose-internals | |
| 2 | 2 | 'use strict'; | |
| 3 | 3 | const common = require('../common'); | |
| 4 | + const { spawnSyncAndExit } = require('../common/child_process'); | ||
| 4 | 5 | const { internalBinding } = require('internal/test/binding'); | |
| 5 | - const os = require('os'); | ||
| 6 | 6 | ||
| 7 | 7 | const { hasSmallICU } = internalBinding('config'); | |
| 8 | 8 | if (!(common.hasIntl && hasSmallICU)) | |
| 9 | 9 | common.skip('missing Intl'); | |
| 10 | 10 | ||
| 11 | - const assert = require('assert'); | ||
| 12 | - const { spawnSync } = require('child_process'); | ||
| 13 | - | ||
| 14 | - const expected = | ||
| 15 | - 'could not initialize ICU (check NODE_ICU_DATA or ' + | ||
| 16 | - `--icu-data-dir parameters)${os.EOL}`; | ||
| 17 | - | ||
| 18 | 11 | { | |
| 19 | - const child = spawnSync(process.execPath, ['--icu-data-dir=/', '-e', '0']); | ||
| 20 | - assert(child.stderr.toString().includes(expected)); | ||
| 12 | + spawnSyncAndExit( | ||
| 13 | + process.execPath, | ||
| 14 | + ['--icu-data-dir=/', '-e', '0'], | ||
| 15 | + { | ||
| 16 | + status: 9, | ||
| 17 | + signal: null, | ||
| 18 | + stderr: /Could not initialize ICU/ | ||
| 19 | + }); | ||
| 21 | 20 | } | |
| 22 | 21 | ||
| 23 | 22 | { | |
| 24 | 23 | const env = { ...process.env, NODE_ICU_DATA: '/' }; | |
| 25 | - const child = spawnSync(process.execPath, ['-e', '0'], { env }); | ||
| 26 | - assert(child.stderr.toString().includes(expected)); | ||
| 24 | + spawnSyncAndExit( | ||
| 25 | + process.execPath, | ||
| 26 | + ['-e', '0'], | ||
| 27 | + { env }, | ||
| 28 | + { | ||
| 29 | + status: 9, | ||
| 30 | + signal: null, | ||
| 31 | + stderr: /Could not initialize ICU/ | ||
| 32 | + }); | ||
| 27 | 33 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments