如何忽略来自节点js的警告

时间:2020-06-17 06:53:22

标签: node.js node-modules

我的nodejs脚本,该脚本有助于将azure门户从一个环境迁移到另一个环境,从而向控制台发出警告,这被我的CI / CD脚本视为错误。(https://github.com/Azure/api-management-developer-portal/blob/master/scripts/migrate.js)。代码片段(来自migrate.js)如下,

// capture the content of the source portal (excl. media)
execSync(`node ./capture ${sourceEndpoint} "${sourceToken}" ${dataFile}`);
// remove all content of the target portal (incl. media)
execSync(`node ./cleanup ${destEndpoint} "${destToken}" "${destStorage}"`);
// upload the content of the source portal (excl. media)
execSync(`node ./generate ${destEndpoint} "${destToken}" ${dataFile}`);
// download media files from the source portal
mkdirSync(mediaFolder, { recursive: true });
execSync(`az storage blob download-batch --source ${mediaContainer} --destination ${mediaFolder} --connection-string "${sourceStorage}"`);
// upload media files to the target portal
execSync(`az storage blob upload-batch --source ${mediaFolder} --destination ${mediaContainer} --connection-string "${destStorage}"`);
if (publishEndpoint && !yargs.selfHosted) {
    process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0;
    publish(publishEndpoint, destToken);
} else if (publishEndpoint) {
    console.warn("Auto-publishing self-hosted portal is not supported.");
}

CI / CD工具使用powershell使此代码自动化。因此,代码在执行时会生成一些警告,Powershell将其视为错误,因为CI / CD工具会返回错误。

我试图通过Powershell脚本中的“ --no-warning”执行脚本,但这对我没有帮助。还尝试将Powershell与&4> 1&3> 1&2> 1一起运行,但遇到相同的错误。

Powershell脚本片段,

Write-Host "migrate --sourceEndpoint "$APIMSourceEndpoint --destEndpoint $APIMDestinationEndpoint --publishEndpoint $APIMDestPublishEndpoint --sourceId $sourceTenantAccess.Id --sourceKey $sourceTenantAccess.PrimaryKey --destId $destinationTenantAccess.Id --destKey $destinationTenantAccess.PrimaryKey
   #Install required libraries to run the migration script
   npm i

   #Execute migration script
   node ./scripts/migrate --no-warnings --sourceEndpoint $APIMSourceEndpoint --destEndpoint $APIMDestinationEndpoint --publishEndpoint $APIMDestPublishEndpoint --sourceId $sourceTenantAccess.Id --sourceKey $sourceTenantAccess.PrimaryKey --destId $destinationTenantAccess.Id --destKey $destinationTenantAccess.PrimaryKey

我得到:

13:22:29   Error    |       Alive[################################################################]  100.0000%
13:22:29   Error    |       Finished[#############################################################]  100.0000%
13:22:29   Error    |       Alive[################################################################]  100.0000%
13:22:29   Error    |       Finished[#############################################################]  100.0000%
13:22:29   Error    |       Alive[################################################################]  100.0000%
13:22:29   Error    |       Finished[#############################################################]  100.0000%

0 个答案:

没有答案