Skip to content

Commit 39d99f1

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 39d99f1

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

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 spesso le esportano così)
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 (alcuni ambienti CI usano queste)
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)