Skip to content

Commit 2b49028

Browse files
committed
Prevent the following error when running yarn generate:
``` UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "npm warn Unknown env config "version-git-tag". This will stop working in the next major version of npm. npm warn Unknown env config "argv". This will stop working in the next major version of npm. npm warn Unknown env config "version-commit-hooks". This will stop working in the next major version of npm. npm warn Unknown env config "version-git-message". This will stop working in the next major version of npm. npm warn Unknown env config "version-tag-prefix". This will stop working in the next major version of npm. ```
1 parent d6045ce commit 2b49028

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

scripts/autogenerate.mjs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,26 @@ import {
1313
javaOldArchDir,
1414
} from './codegen-old-arch.js';
1515

16+
// --- sanitize npm env to avoid "Unknown env config" warnings on stderr ---
17+
process.env.NPM_CONFIG_LOGLEVEL = process.env.NPM_CONFIG_LOGLEVEL || 'silent';
18+
19+
[
20+
// lower-case (POSIX shells export them like this)
21+
'npm_config_version_git_tag',
22+
'npm_config_argv',
23+
'npm_config_version_commit_hooks',
24+
'npm_config_version_git_message',
25+
'npm_config_version_tag_prefix',
26+
// upper-case (some CI environments use these)
27+
'NPM_CONFIG_VERSION_GIT_TAG',
28+
'NPM_CONFIG_ARGV',
29+
'NPM_CONFIG_VERSION_COMMIT_HOOKS',
30+
'NPM_CONFIG_VERSION_GIT_MESSAGE',
31+
'NPM_CONFIG_VERSION_TAG_PREFIX',
32+
].forEach((k) => {
33+
if (k in process.env) delete process.env[k];
34+
});
35+
1636
// process style spec json into json
1737

1838
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));

0 commit comments

Comments
 (0)